0

I need to include a js file on all browsers (IE less than 11).

I have this in my header

<!--[if lt IE 11]><!-->
    <script>
        console.log('shouldnt see this on ie less than 11.');
    </script>
    <script type="text/javascript" src="/nothinglikeit/js/ie.js"></script>
<!--<![endif]-->

Funny enough, this works on IE9, but it DOESN'T work on ie10? Why is that?

From what I've read, IE10 ignores conditional statements, however I do need to include it regardless, is there a way I can do this with conditional statements?

Shannon Hochkins
  • 9,930
  • 11
  • 50
  • 88
  • 1
    What is in your `ie.js` that you want excluded from IE10? If it's because a specific feature is unsupported then use feature-detection instead of browser-detection. – Dai Nov 12 '15 at 02:55
  • 1
    First search result https://msdn.microsoft.com/en-us/library/hh801214(v=vs.85).aspx (Conditional comments are no longer supported) – Ben Nov 12 '15 at 02:55
  • 1
    Possible duplicate of [How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?](http://stackoverflow.com/questions/9900311/how-do-i-target-only-internet-explorer-10-for-certain-situations-like-internet-e) – Ben Nov 12 '15 at 02:56
  • @ben dam you beat me to it LOL – jeff Nov 12 '15 at 02:56
  • @Ben I did say that in my post, I'm asking if you can do it another way. – Shannon Hochkins Nov 12 '15 at 03:08
  • @dai I don't want to include libraries on a browser, just to then check with js if it supports it or not. I'd rather conditionally include the libraries. – Shannon Hochkins Nov 12 '15 at 03:08
  • @ShannonHochkins You **don't need** to use any additional libraries (like Modernizr), you can do the checks with exactly 3 lines of JavaScript. – Dai Nov 12 '15 at 03:34
  • @Dai I think you've misunderstood. Say I have an animation library I don't want to included on IE10, purely because it's another resource it has to load. I would have to do this check with js, then include the actual file if I want to or not. I'd much rather just do this with conditional statements, but obviously it doesn't sound like this is possible. – Shannon Hochkins Nov 12 '15 at 03:43

0 Answers0