Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Modernizr to the bottom #1605

Closed
paulirish opened this issue Sep 23, 2014 · 17 comments
Closed

Move Modernizr to the bottom #1605

paulirish opened this issue Sep 23, 2014 · 17 comments

Comments

@paulirish
Copy link
Member

It has more potential to introduce unexpected situations, however it's much better for the user to just have no scripts up in the head at all.

Guide to Using Modernizr responsibly.

I bet >75% of sites dont need it in the head. I'd rather change this default and educate the 25% than watch as we slow down all these sites.

@arthurvr
Copy link
Member

I agree that loading scripts at the bottom is mostly better, but html5shiv is included with modernizr, so in older browsers the page might render wrong when modernizr is loaded at the bottom?

@bartveneman
Copy link

You should inline the HTML5Shiv in an inline script tag at the top of the document. This should not need to be a network request.

@arthurvr
Copy link
Member

@bartveneman True. I agree.

Once the support for ie8 is dropped, do we still need html5shiv? (#1524)

@patrickkettner
Copy link
Contributor

+1, no need for modernizr to be in the head for a lot of the sites that use it. As long as modernizr properly documents why you would ever actually want it in the head, theres no reason to slow down the internet with this recommendation.

image

@TheDutchCoder
Copy link

+1. People can always move it back to the head in those cases where it's needed / justified, but it's better to present them with the best possible scenario.

@alrra
Copy link
Member

alrra commented Sep 25, 2014

@paulirish, @patrickkettner Care to open a PR that makes the change and also updates the docs? :)

@alrra alrra modified the milestone: 5.0.0 Sep 27, 2014
@ghost
Copy link

ghost commented Oct 8, 2014

Why isnt this merged

@bnjmnt4n
Copy link

bnjmnt4n commented Oct 9, 2014

Why isnt this merged

@emoju:
It’s not a pull request, just an issue created to provide a suggestion. It’s currently awaiting feedback.

@paulirish
Copy link
Member Author

I would like to work on the PR & Docs but don't have the time to. We need to communicate this on the modernizr side primarily. I'd welcome any help with the communication -- basically we need a revision of my article/comment that we publish to help transition existing users to more responsible use of it and justify the change in recommendation.

@roblarsen
Copy link
Member

@paulirish I'm through the book grind, so I've got some time to help out with documentation. Let me know what you need.

@alrra alrra modified the milestones: 5.1.0, 5.0.0 Oct 20, 2014
retlehs added a commit to roots/sage that referenced this issue Oct 24, 2014
@austinpray
Copy link

Has anybody tried this out on real sites yet? What patterns are most likely to make a site fall into the 25%?

@patrickkettner
Copy link
Contributor

@austinpray relying on modernizr for styling/creating the above the fold content

@drublic
Copy link
Member

drublic commented Dec 7, 2014

We will test this within the next couple of weeks in a large scale project. I will provide the results if possible.

@austinpray
Copy link

thanks @drublic

Would be interested to hear results.

@arthurvr
Copy link
Member

@drublic Do you already have (some?) results?

@drublic
Copy link
Member

drublic commented Jan 13, 2015

We don't have a lot of numbers from our production websites yet but here are some test numbers:

We now load html5shiv in header.min.js and our Modernizr custom build in core.js. Before the change, Modernizr was loaded in header.min.js too.

The change saves us in header.min.js
gzipped 3.4KB (2.7 KB compared with 6.1 KB before)
unzipped 10KB (5.6 KB compared with 15.6 KB before)

The saved data moves to core.js
gzipped 2.6 KB (82.4 KB compared with 79.8 KB)
unzipped 7 KB (258 KB compared with 251 KB)

This means we save bytes (because of how gzip works) and deliver the first view faster.
We did not encounter any problems with rendering within our project.

@alrra alrra removed this from the 5.1.0 milestone Apr 1, 2015
@alrra alrra removed this from the 5.2.0 milestone Apr 30, 2015
@roblarsen roblarsen modified the milestone: 6.0.0 Sep 30, 2016
roblarsen added a commit to roblarsen/html5-boilerplate that referenced this issue Apr 21, 2017
Fixes h5bp#1740 and h5bp#1605

- removes the static custom build of modernizr
- moves Modernizr to the bottom
- builds a custom modernizr in gulp
- adds tests for the generated modernizr
roblarsen added a commit to roblarsen/html5-boilerplate that referenced this issue Apr 21, 2017
Fixes h5bp#1740 and h5bp#1605

- removes the static custom build of modernizr
- moves Modernizr to the bottom
- builds a custom modernizr in gulp
- adds tests for the generated modernizr
roblarsen added a commit that referenced this issue May 28, 2017
Fixes #1740 and #1605

- removes the static custom build of modernizr
- moves Modernizr to the bottom
- builds a custom modernizr in gulp
- adds tests for the generated modernizr
@roblarsen
Copy link
Member

ayo, I merged in code that does this 💯

jeffreznik pushed a commit to jeffreznik/sw-test that referenced this issue Oct 15, 2017
Fixes h5bp#1740 and h5bp#1605

- removes the static custom build of modernizr
- moves Modernizr to the bottom
- builds a custom modernizr in gulp
- adds tests for the generated modernizr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants