Search code examples
htmlcsshtml5shiv

Where to put link to html5shiv.js? Before css <styles> or with other <script> tags?


As I understand html5shiv.js file "teaches" browsers like IE to process CSS3 properly:

<!--[if lt IE 9]>
    <script src="scripts/html5shiv.js"></script>
<![endif]-->

Where should I include it - before styles tag or at the bottom of the page?

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <!-- Where to put this link to html5shiv? -->
    <!--[if lt IE 9]><script src="scripts/html5shiv.js"></script><![endif]-->
    <link rel="stylesheet" href="some.css"/>
</head>
<body>

    <!--html content -->

    <!-- scripts should be loaded after DOM is constructed -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script type="text/javascript">
        // some scripts here..
    </script>
</body>
</html>

Solution

  • If you get started with a new tool or code snippet or library and you don't understand it at a first glance, you really should start reading the manual!

    Include the HTML5 shiv in the of your page in a conditional comment and after any stylesheets.

    See: https://github.com/afarkas/html5shiv