Modernizr and Content Delivery Networks (CDNs)
One of the most common requests around Modernizr is for it to be made available on a Content Delivery Network. Back in the 1.x days this made a fair bit of sense: there was only one version of the library, and so the compressed version would be useful to have on a CDN for performance reasons.
With the advent of Modernizr 2, however we’ve (re)introduced modular builds of the library, which make the value of CDNs less self-evident. We now make you create a customized build of Modernizr—using only the tests you actually need—when you want a production-ready, minified & compressed version of the library. But with over 40 embedded tests, supporting all possible combinations of tests is impossible, aside of being downright undesirable.
This has caused some confusion, so we’d like to explain the right way to use Modernizr under the various different scenarios that occur.
Development, local: General development and/or learning
When you start building a new project, or if you simply want to learn, you should download the latest development version of Modernizr. This is typically a stage where you don’t know yet which feature detection tests you’ll eventually need by the time you go to production, and don’t need to worry about minification. If you’re building your site or app locally, this is the version to use.
Development + CDN: Test cases, one-offs, partial control-situations
If you’re creating a quick test case using something like jsfiddle, or are writing an entry for a contest like 10K Apart, using a CDN can be not just useful, but downright necessary. If your situation relies on externally-hosted code, use one of the CDN releases.
But be warned: these versions contain all 40+ tests! That means they are full-fledged libraries with almost certainly a lot of things you don’t need in a final product.
That’s why the Microsoft CDN and CDNJS releases of Modernizr are essentially just Development versions, but hosted somewhere for you to use.
Custom build: All production uses
Are you priming your website or app for production? Then it’s time to head over to the custom download builder, tick all the tests your project makes use of, and hit that Generate button to make your own special build.
All production uses of Modernizr should be using a latest custom build from the site. This ensures that you won’t run into any (old) bugs, and will have the absolute minimum amount of code and execution time needed for the best possible performance.
As an added bonus, these custom builds now include a directly-usable Build link that allow you to make small tweaks—change a setting here or there—without having to figure out your requirements all over again. It’s also helpful whenever a new stable build is released: just revisit that Build link from your custom build’s source, hit Generate again and you have a new, updated stable build. Always be sure to test!
We hope this simple guide helps you figure out when to use what version of Modernizr.