2 ms·
IMHO, websites should include a single js file. In development you can have 100 js files, but in production these should be combined into a single file. The do
by kqueue 16y ago
IMHO, websites should include a single js file. In development you can have 100 js files, but in production these should be combined into a single file.
The downside is that you might include things you don't need in all pages, but that's not an issue because the file is transferred once, and cached. This will also minimize future conditional GET requests that check wether the cached file has changed or not.
- superk 16y agoI'm not sure I agree with this. I don't think a user should have to re-download all the JS on the site if I just change a single line. Small changes probably happen frequently and shouldn't invalidate the entire JS cache. If I were using a framework like jQuery, I would link that separately from a 3rd-party CDN like Google. Then all the shared behavior would be another request, and page specific code a third. In most cases I would be changing the page specific code which would only invalidate the cache for that request on that page. IMO that's a better compromise.