h5bp/html5-boilerplate — pull request #906 by gzoller (2012-01-06 00:00:31+00:00)
Title: Support for js modules with cachebusting

Currently Boilerplate smushes all your javascript code into one file (scripts.js) and munges the name to bust long-lived client-side caches.

This is great but what if you have a lot (a _lot_) of javascript code that is per-page or per-module? (Think backbone.js with all of its component-specific models, views, etc.) This is structural code well beyond shared scripts for tooltips, etc. Today this would create the mother-of-all-script.js files. On a fresh cache you'd have to download this huge file containing all this module-specific javascript for your entire application making first-page access longer than it needs to be.

With this patch, if you create a js/modules directory the build script will minify but not concatenate any files in that directory. In the publish/js directory the js/modules directory itself will be renamed to a munged name and the appropriate html references modified. The files within the now-renamed modules directory won't have their name changed. This provides cache-busting and controlled granularity without affecting what Boilerplate already does.

If you don't have a js/modules directory, or it is empty because you don't need this feature, nothing bad happens.