0

I would like to update the jQuery library on my site, but when I use the newer versions (2+?) certain things stop working when using IE 8 or below.

After reading more than several posts about using alternate versions of jQuery depending on certain conditions, I have a couple questions about the actual implementation - refer to the versions below:

VER1

  <![if !IE|gte IE 8]>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <![endif]>

  <![if lt IE 9]> //(COMMENTED OUT)
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <![endif]>

VER2

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <![if lt IE 9]> //(COMMENTED OUT)
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <![endif]>

First Question: Both versions seem to be work as expected so far. In VER2, will IE8 and below browsers end up loading two versions of jQuery (which as I understand it, can cause issues)?

Second Question: Would VER1 be an acceptable or conventional implementation of what I am trying to achieve?

Tron
  • 167
  • 12
  • Side Note: https://stackoverflow.com/questions/13785587/if-ie-not-working – Taplar May 10 '18 at 19:23
  • here's one of the posts, but I don't think it addresses weather or not you need to put ALL jQuery versions in conditional statements if you have more than one: https://stackoverflow.com/questions/22251261/conditional-comments-alternative-to-load-jquery – Tron May 10 '18 at 21:27
  • I think you missed the point of the page I linked. The point being IE 10 and beyond do not support the conditionals at all. – Taplar May 10 '18 at 21:30
  • does that mean that IE10+ will still be loading 2 different versions of jQuery? Same for other browsers? I think you're right, I'm missing the point. – Tron May 10 '18 at 21:42
  • That is accurate. I verified it in IE 11. – Taplar May 10 '18 at 21:49
  • I just added two scripts containing console.log();s inside of each conditional statement, I ran IE 8,9,10,11 and a new instance of chrome, in each case I only saw one of the console.log()'s, and the output was correct in each case, meaning I never saw both scripts load. In what case will this allow both to be loaded? – Tron May 10 '18 at 21:53
  • I took exactly what you have for your VER2 snippet (minus the //COMMENT part), put it in a head on an blank html page, opened IE 11 and recorded the network traffic. Both the 3.3.1 and 1.7.2 resources were requested. – Taplar May 10 '18 at 21:54
  • ahh, I see what you mean, I'm looking at the same thing and even seeing it on 8 and below. Can you point me in the right direction? Also, why is this the case when it seemed on the surface to be working with the console.log(); test? – Tron May 10 '18 at 22:11
  • Others may be able to advise you on this issue. Personally I would probably error on the side of having a single library version that works with all the browsers you are required to support, OR, if you do include a version that is lacking functionality with older versions of IE that you must be able to support, it's also a possibility to provide shims for the functionality that the older versions are missing so you can keep using just the newer versions of the library. – Taplar May 10 '18 at 22:13

0 Answers0