Search code examples
htmlinternet-explorerbrowserconditional-comments

Don't load a script in IE8 and below?


This question must be a duplicate, but I can't find the definitive answer on here.

How can I tell the browser not to load a script, if the browser is IE8 or below?

I know about targeting IE9 and above:

<!--[if gte IE 8]>
 According to the conditional comment this is IE 8 or higher<br />
<![endif]-->

but then the script does not load in non-IE browsers.

How can I say "load the script if not IE, or if IE and greater than IE8"?


Solution

  • Conditional comment for 'Except IE8'?

    <!--[if gte IE 9]><!-->
        // Your script here. This will only be loaded if IE version is greater than 8, OR any other browser.
    <!--<![endif]-->
    

    Should work?