3 ms·
This advice breaks if you have more than one type of page on your site: you don't want to have browsers processing tons of JS which isn't needed for the current
by acdha 14y ago
This advice breaks if you have more than one type of page on your site: you don't want to have browsers processing tons of JS which isn't needed for the current page, especially on mobile. Even if it's always cached (not even remotely true), there's a non-trivial amount of parser overhead and memory usage.
What I prefer to do is have a common bundle for the JS used on every page, bundles for each distinct type of page, and separate polyfills for old browsers. This improves your initial cold-cache load time for every page, avoids penalizing new browsers because other people use antique browsers and avoids cache churn by invalidating the entire bundle every time you change anything in one JS file.