On 6/19/2013 12:46 PM, Boris Zbarsky wrote:
On 6/19/13 3:43 PM, Kenneth Russell wrote:
Accurate feature detection in libraries like Modernizr was mentioned
as a key use case:
http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-September/037249.html
Right, this is the use case that's not really making sense to me. The
fact that Modernizr was doing this _eagerly_ sounds like a bug in
Modernizr to me...
The point of using Modernizr or something like it is to detect
availability of features on page load, and then conditionally load
polyfills/alternate fallback implementations. It specifically does need
to do eager detection to be useful. It can't wait until the first usage
to do feature detection; it needs to be done up front when preparing
dependencies for the main application.
This is also why Modernizr provides a custom build tool. It allows for
users to only do the feature detection on features they know they need
to care about, because each check has some cost that needs to be paid
early on in a page load.