Search code examples
htmlinternet-explorerinternet-explorer-9conditional-comments

Target everything but IE 9


Is there a way to only prevent IE 9 from loading a stylesheet or script?

I just found a way to prevent all IE versions from doing something but not a certain version:

<!--[if !IE]><!-->
    <link rel="stylesheet" href="not-ie.css" />
    <script src="not-ie.js"></script>
<!--<![endif]-->

Solution

  • Sure, just specify the version:

    <!--[if !(IE 9)]><!-->
        <link rel="stylesheet" href="not-ie-9.css" />
        <script src="not-ie-9.js"></script>
    <!--<![endif]-->
    

    Note that what you currently have will result in IE10 and later loading your resources like other browsers, as those newer versions do not process conditional comments.