In order to keep my sites as fast as possible, I prefer loading .js scripts at the end of the document, just before the closing body tag, reserving css for the HEAD section. However, I’ve found that the html shiv code below apparently only works when instantiated in the HEAD section.
<!--[if lt IE 9]>
<script type="text/javascript"
src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
Anyone know of a workaround?
The way the HTML5 shiv works requires you to put it in the
<head>element. In fact, it says so in the project page: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.1
1 But as others have mentioned, since Google Code isn’t actually a CDN, you should pick another source.