Suppose i have some scripts which are common for all the pages and some scripts which are required only on specific page what is the efficient way to implement this using nunjucks as template engine and express 4 as the framework on backend.
--- site
--- public
|___js
|___ script.js (for all pages)
|___ home.js (only required on home page)
|___ contact.js (contact page)
|___ search.js (on search page)
I have tried to use express locals for passing in the page title and sending the array of common scripts + home.js but on rendering script tags theres another call made to express middleware for route (*) which resets the scripts to common as no page title is passed to the function.