But say I wanted to require a file called scripts/filters.js only on the About page. What is the best way to require certain modules in this way using Sage conventions?
Couple things to note: the source dir of the new file is the theme root and notassets/ like the existing manifest, so you’ll need to account for that in your source paths. Also, libraries you install via Bower must be included manually (otherwise they won’t be built into your main.js).
You would enqueue about.js separately and conditionally, it will not be included in main.js.
If you want the script itself to fire only on certain pages then please be sure to read the comments on DOM based routing and use main.js as a template for your new file.
Cool, so if I go the second route–to avoid main.js from becoming unwieldy with js code-- what is the best way to “require” other views/javascript files ?