#Bundled Javascript file per route?

2 messages · Page 1 of 1 (latest)

gusty breach
#

Hi there,

I don't know if I've a config issue or if this is the intention but say I've a single page that's got 10 components with a fair bit of vanilla JS in each component.

Then I've the homepage, and it uses 3 of these components.

At the moment, there just seems to be a single hoisted.js file for the whole site, meaning the homepage loads all the JS even if it doesn't need all the contents.

Is there a way to chunk the js up to behave like .css does? A .css file per per route like .css is handled.

Thanks

gusty breach
#

I ask this because the language on the docs always says "page" rather than "site'.

Eg: "Astro will build, optimize, and add these scripts to the page for you, following its script bundling rules."