I’m trying to work out the best way to upgrade jQuery.
Let’s say I am using jQuery v1.4.4, and I want to upgrade to 1.7.1.
If I want to update, should I remove jquery-1.4.4.js completely from my project or should I keep jquery-1.4.4.js in addition to jquery-1.7.1.js?
Also there may be some jQuery files that may be referencing jquery-1.4.4.js, What is the best way of upgrading these cases?
A new version of jQuery should completely replace the old version, so you could remove the
<script>that included the old version and replace it with a new<script>block.You will find that a jQuery update does not normally include many breaking changes (changes that will break code used with a previous version), and so, for the majority of cases, you should not get any problems when you upgrade.
However, to be sure, you should look at the release notes for the version you’re upgrading to (and indeed, all the versions you’re bypassing), to check you won’t be affected by any of the changes.
Code does not reference a specific version of jQuery. Code that uses jQuery simply uses the jQuery methods and constructors (
jQueryand$), and expects a certain method signature (form of accepted parameters and return type). Upgrading to a new version might remove these methods or change the signature of them, and it’s this you need to watch out for.