EricBellDesigns
EricBellDesigns

Reputation: 965

Confusion around multiple jQuery versions, .noConflict, and jQuery migrate

I have a project that is a massive website, and I was brought in to make the website responsive. I went with bootstrap for the framework, and quickly ran into issues with the jQuery version being used (v1.8.2). I solved my issues in a development environment by adding the following script references:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script> 

I using $.noConflict(); but I do not believe it was in the correct spot. I called it after the three script references (old jquery, new jquery and jquery migrate). When we built the website to a staging environment, I am getting several script errors.

I read other questions similar to this, and found the following code:

<script src='jquery-1.6.2.js'></script>
<script>
  var jq162 = jQuery.noConflict();
</script>
<script src='jquery-1.9.1.js'></script>
<script>
  var jq191 = jQuery.noConflict();
</script>

This does not use the migrate script. I have also seen the opposite where .noConflict is not called and only the migrate script is used.

Is one method considered better than the other? Or do I need to use both?

Upvotes: 2

Views: 684

Answers (1)

NoConflict function isn't for these purpose. The NoConflict is used to skip from conflict between JQuery and others frameworks with use the $ shortcut, like the Prototype framework. Conflict between diferents JQuery must be resolved used one of them and removing the other (with preference keep the newest).

Upvotes: 0

Related Questions