How to use main.js in Sage 9

Hi everyone,

I’ve been trying to put together a site with Sage 9, and I can’t for the life of me figure out how to add jQuery into the main.js scripts file. It has changed since Sage 8, and the build fails with “npm run build” when I directly add jQuery there. Below is what the page specific Sage 9 main.js looks like now.

Do I need to specify “Init” and “Finalize” somehow? My guess is yes, but I’m not clear on how to do that.

const routes = {
// All pages
// Home page
// About us page, note the change from about-us to aboutUs.


1 Like


Oh… I get it. I saw those, but didn’t connect the dots that I had to put the javascript inside of THOSE files, and not in the main.js file anymore.

Thanks so much!


20 damn chars

Bump. Link is broken and the Sage 9 docs don’t describe main.js yet … But the answer is there in the next post. Add your JS to to the .js files in the scripts/routes/file.js files :smiley: