Roots Discourse

Sage9 exclude pages from using common.js?

I have a site where the navigation is required on all pages apart from the home page - rather than create .js files for each page individually, I was wondering if it would be possible to use common.js but exclude it from being loaded on the home page. Is this possible?

Thank you!!

Aren’t all JS files bundled into one single JS file anyway and the router calls the right route functions?
webpack can do code splitting.

The router is just matching against classes in the body for each page. You could wrap your code in common.js with a conditional that checks for home or something and executes code accordingly. That would only affect what code runs, though: all your JS is compiled into a single file (by default) so it all gets downloaded regardless of the page you’re on.

You could wrap your code in common.js with a conditional that checks for home

This is what I’m after, thanks.