imak
imak

Reputation: 6699

How do I go about upgrading jQuery in my project?

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?

Upvotes: 3

Views: 6574

Answers (2)

tkone
tkone

Reputation: 22728

Yes replace the script tag for the old version with the new one.

The only way another file, on the client side (unless you're using LAB or something similar) is by including a script tag in your HTML page. Without any loaders JavaScript files cannot call out to other JavaScript files.

That being said make sure you test thoroughly before deploying!

Upvotes: 0

Matt
Matt

Reputation: 75317

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 (jQuery and $), 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.

Upvotes: 3

Related Questions