Closed (fixed)
Project:
Modernizr
Version:
7.x-3.4
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Apr 2014 at 17:59 UTC
Updated:
7 Jan 2015 at 13:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
ruplWhaddya know: https://github.com/Modernizr/Modernizr/issues/878#issuecomment-41448059
Comment #2
ruplHere's the patch. It defers by default, per discussion on GitHub in comment #1.
You should see markup similar to the following after applying the patch:
If you visit
/admin/config/development/modernizr/settingsthere is an option to switch back to synchronous loading, and if you select it thedeferattribute should be removed entirely.Comment #4
ruplCommitted to dev!
Comment #8
ruplIt was brought to my attention that using this new
deferoption along with our Drupal-poweredModernizr.load()results in an error because you can'tdeferinline scripts.So the reference to modernizr.js is deferred, but the Modernizr.load() code is *not* deferred, runs immediately, and produces an
Uncaught ReferenceError: Modernizr is not defined.I think the quickest fix might be to detect if
hook_modernizr_load()produces anything, and if it is being used then we manually remove thedeferattribute. A longer-term fix would be to cache the Modernizr.load() code in a Drupal-cached file (similar to aggregates) so that both scripts can be deferred.More info about
deferavailable on MDN.Comment #9
ruplReclassifying issue to match current situation.
Comment #10
katzmo commentedSince modernizr is used for browser compatibility IMHO the default settings should work for as many use cases as possible, especially in old browsers, and not break existing installations. Defer does both. (See http://caniuse.com/#search=defer and Known Issues for browser compatibility)
So why not keep 'synchronous' as default setting? If you don't need things like html5shiv and rather load modernizr asynchronous, then you may change your settings accordingly!
Comment #11
ruplYou're right. I should have fixed this a month ago anyway when I discovered the problem in comment #8.
Comment #13
marcvangendI completely agree with #10. This fix would have saved me 2 hours of figuring out why the html5shiv wasn't doing anything in IE8.
This issue is fixed I guess. A new release would be appreciated!
Comment #15
ruplMy sincere apologies :( There is a new release now.
edit: https://www.drupal.org/node/2403197