Legionar Legionar - 3 months ago 7
jQuery Question

jQuery two versions loaded on one site

I just found one website, where are two versions of jQuery included in HTML and both loaded. All scripts on the website are working without problems.

Is there any reason for doing that? Thanks.

<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Answer

There is no reason to do so, and it seems like the programmer was trying to upgrade to version 2, but for some reason it didn't work and he decided to go back to version 1 and forgot to remove the <script> tag of version 2.

The second <script> line will load version 1 of jQuery and will override version 2.

Here is an example:

console.log("jQuery active version is: " + $.fn.jquery)
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>