2

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?

8
  • can you be more detailed on I am getting several script errors ? show one or some of those errors please. and did you read some of this: api.jquery.com/jquery.noconflict ?
    – caramba
    Commented Oct 23, 2015 at 22:54
  • Sure, here's an example: Uncaught TypeError: Cannot read property 'webkit' of undefined Commented Oct 23, 2015 at 22:56
  • I did read the jquery documentation for noconflict, and it seemed to be a little different than the way it was used in the answers I found on StackOverflow. It seems to call the newer jQuery first, then the older version. Would this be preferred? Commented Oct 23, 2015 at 22:57
  • noConflict() has nothing to do with newer or older versions of jQuery but why should I tell if read the docs ... while reading this github.com/jquery/jquery-migrate I would just load ONE jQuery version and the migrate ...
    – caramba
    Commented Oct 23, 2015 at 23:08
  • @caramba thank you for your answer. I see that jQuery migrate only uses ONE version, then calls the migrate script. I am concerned that removing the first reference will cause errors, but I will test that next. It seems noConflict() does have to do with the newer or older versions though. Why else would the above code (from the question I found) be used? Commented Oct 23, 2015 at 23:30

1 Answer 1

0

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).

Not the answer you're looking for? Browse other questions tagged or ask your own question.