0

I am in the process of learning developing web applications. While building different components of the application, I take help from online examples and try and see if it helps in achieving my functional objectives. In one of my application I am using two different versions of jQuery.

<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script> 

I tried, removing 1.12.4 version and ran my application, and it did work without any trouble.

My question is, is it really necessary to have both these libraries? Do they provide different functions or is 3.1 is actually an upgrade of 1.12.4.? In other words, does 3.1.0 have all the functions of 1.12.4?

When my application worked correctly, without one of the library, is it because that the functions were held and the cache and was getting referred to?

Quite confused.

I am sure this is a generic question and afraid if this qualifies for downvoting. But for a self learner like me, the guidance from the community is not only valuable but also helps me understand whatever I am doing is right or wrong.

Apricot
  • 2,925
  • 5
  • 42
  • 88
  • You do not need to use both, And both library can provide different functions. But, most probably using latest one would be good. – Just code Oct 05 '18 at 04:50

2 Answers2

0

It is not necessary, in fact you should avoid using importing multiple jquery versions if one of them covers your all cases, because it almost prone to error, conflicts. If you really need to have the two files together in your project for some reason below importing config helps and see the related post

<!-- load jQuery 3.1.0 -->
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script type="text/javascript">
var jQuery310 = $.noConflict(true);
</script>

<!-- load jQuery 1.12.4 -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script> 
<script type="text/javascript">
var jQuery1124 = $.noConflict(true);
</script>
ibubi
  • 2,469
  • 3
  • 29
  • 50
0

My question is, is it really necessary to have both these libraries?

No, you don't have to. I guess the library included last must have overridden the definition of jQuery as you have not used noConflict() method

Do they provide different functions or is 3.1 is actually an upgrade of 1.12.4.?

There may be some methods that are deprecated and some may have stayed. Refer https://blog.jquery.com/2016/07/07/jquery-3-1-0-released-no-more-silent-errors/
https://api.jquery.com/category/version/3.1/
http://blog.jquery.com/2016/05/19/jquery-migrate-1-4-1-released-and-the-path-to-jquery-3-0/

My 2 cents:
Use the latest one and if there are some issues, you can use jquery migrate plugin https://jquery.com/upgrade-guide/3.0/ till you resolve the broken the code.

Aditya Sharma
  • 645
  • 1
  • 10
  • 28