Why is Chrome ignoring IE conditional tag?

I’m using a custom bootstrap wordpress theme.

My head is created as per Bootstrap recommendations

Read More
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?>
<!--[if lt IE 9]>
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<?php wp_head(); ?>
</head>

I may be misunderstanding the signifigance of the IE condtional tag, but I expected the IE hack code to only load in IE, however all of these scripts are present in Chrome.

Am I misusing this tag? Is there another recommended way of making sure these scripts only load for IE browsers lighter than version 9?

I prefer to keep my pages as light as possible, so I don’t want unnecessary code loading just to appease the silly few still using ie8 and below.

Related posts

Leave a Reply

1 comment

  1. --> ends a comment. So, the end of this comment:

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    

    is also the end of the part that is a comment to the Chrome rendering engine.

    The solution is easy: just move your comment tags outside of the IE conditional.

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->