html5shiv icon indicating copy to clipboard operation
html5shiv copied to clipboard

Can someone help me understand how this works

Open bryanwillis opened this issue 9 years ago • 2 comments

I've been using html5shiv for years now. I have a mac so I've never actually seen what it does beside a browserstack test I did a year or so back.

I guess what I'm confused is how this is supporting IE9, Safari 4, And FF 3. My best guess on Safari 4 and FF 3 is that they recognize IE conditional comments somehow. But this still doesn't explain that how this supports IE9.

Usage / documentation has always been suggested implementing like this:

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

To support IE 9 shouldn't this be something like ...

<!--[if lte IE 9]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->

Personally I use either css reset / bootstrap / html5 boilerplate on all my sites so the IE9 styling doesn't affect me one way or the other I'm just curious / confused on what I'm missing here...

bryanwillis avatar Jan 12 '16 03:01 bryanwillis

Logically seems this would be the best way to include it so it works for IE9 and wont render in IE5:

<!--[if !(IE 5)]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->

bryanwillis avatar Jan 12 '16 03:01 bryanwillis

Your proposed conditional comment <!--[if !(IE 5)]> is not a valid syntax for conditional comments in Internet Explorer. Conditional comments use specific syntax that includes checks for versions, not boolean conditions like "!(IE 5)".

If your goal is to include the HTML5 Shiv for IE9 and above while avoiding rendering for IE5, you can use the following conditional comment:

<!--[if gte IE 9]>
    <script src="bower_components/html5shiv/dist/html5shiv.js"></script>
<![endif]-->

boorge avatar Oct 16 '23 17:10 boorge