Conditional comments not working in ie11

1.3k Views Asked by At

I'm trying to use conditional comments to load webcomponents polymer polyfill on ie11 and webcomponente-lite polyfill on ohter browser so I have:

<head>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/roboto-condensed/css/roboto-condensed.css">
<!--[if IE]>
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<![endif]-->
<!--[if !IE]><!-->
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!--<![endif]-->

The issue is that webcomponents-lite.min.js is always loaded, event in IE11

Any suggestion?

1

There are 1 best solutions below

0
ajm On BEST ANSWER

IE 11 does not support conditional comments.

Conditional comments are no longer supported

Impact Applies to Internet Explorer 10 and later. Affects IE10 Standards mode and later, including interoperable quirks mode. Support for conditional comments has been removed in Internet Explorer 10 standards and quirks modes for improved interoperability and compliance with HTML5. This means that Conditional Comments are now treated as regular comments, just like in other browsers. This change can impact pages written exclusively for Windows Internet Explorer or pages that use browser sniffing to alter their behavior in Internet Explorer.

You'll need to try another way to target IE11 specifically.

Searching around SO brought me to this answer, which uses feature detection to determine whether or not to load Polymer's polyfills.