Html5shiv Only Works When In Head Section?
Solution 1:
Google code is NOT a CDN. Don't link files in trunk.
Look at the response headers :
Cache expires after 3 minutes... it's the exact opposite of what we want from a CDN.
Please stop doing that.
Note
As João Cunha commented, you can find real CDN links on cdnjs.com: html5shiv. (respond.js can be found there as well)
Sample:
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/respond.js/1.4.2/respond.js"></script>
<![endif]-->
Solution 2:
The way the HTML5 shiv works requires you to put it in the <head>
element. In fact, it says so in the project page:
To use this script, it must be included before the
<body>
element (i.e. in the<head>
) but doesn't matter if it appears before or after the CSS - but for the sake of performance, it would make better sense to include the CSS first then this script.
This is so IE can recognize the HTML5 elements before it starts constructing the document body.
There is no workaround for this.
The lesson here is not to obsess over putting all your scripts at the end of the page. A CDN is pretty darn quick at serving stuff, so you shouldn't need to move this particular script.
But as others have mentioned, since Google Code isn't actually a CDN, you should pick another source.
Post a Comment for "Html5shiv Only Works When In Head Section?"