19

When you recommend updating jQuery/jQuery UI? Or in other words: what are the best practices for updating jQuery/jQuery UI?

I’m working on a long project that will take at least one more year. In that time span, I’m sure that jQuery/jQuery UI will be updated many times.

Do you recommend update my jQuery/jQuery UI files every time an update is released? Or is better to stick with a particular version until the end of the project?

I’m afraid of “breaking” code changes, and every time an update is released, I have to test everything. That takes too much time. But on the other hand, if I didn’t update, I’m afraid of bugs that later will bite me in the rear.

The project is an ASP.MVC and I use jQuery a lot.

Any thoughts?

yannis
  • 39,547
  • 40
  • 183
  • 216
  • This article may be relevant: it urges *always* being at the tip by linking to the Google-hosted version: http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/ – Alex Feinman Dec 17 '12 at 15:52

7 Answers7

21

You should upgrade with each release of jQuery -- just take a peek at the update logs before updating.

The jQuery team is very good about documenting API changes and deprecated calls. At this point, the vast majority of the API is quite stable and probably won't change. Most changes are behind-the-scenes bug fixes that do not affect the outward API. This is especially true with the latest releases (1.8+).

Another great reason to update is because regardless of whether or not you remain on a project, that project will be maintained by somebody after you're done with it. Upgrading to latest version is beneficial for you, future developers and users -- because the newer versions of jQuery blow the older ones out of the water... so go ahead and update the thang.

Cory Danielson
  • 310
  • 1
  • 6
  • 4
    This should be the accepted answer, leaving it just means when you finally do want to upgrade you have to make larger version jumps which is much harder. – Daniel Little Feb 11 '13 at 04:59
20

Update your version of jQuery if and only if you need some new feature that's included in the new version. Simple as that.

If you frequently develop using jQuery, keep an eye on the official blog to know when updates are released and what they offer. Wait a couple of weeks or so before upgrading to the latest version to make sure any unexpected bugs get shaken out.

Blazemonger
  • 348
  • 3
  • 5
  • 1
    +1 it's the most stable way to do it, upgrading for the sake of upgrading increases your overall development time when you end up fighting bugs. – Nicholas Smith Oct 10 '11 at 12:47
  • 2
    Also, keep an eye on your plug-ins. Sometimes a plug-in's bug fix requires upgrading the core jQuery code. – Adrian J. Moreno Oct 10 '11 at 15:57
  • 12
    I disagree with this answer. If the product is still in development, as it sounds like from the question, then upgrade with each new release of jQuery. If the product is in production, then I agree with this answer, upgrade only when an upgrade is required (bug fixes, new feature.. etc) – Chuck Conway Dec 17 '12 at 18:13
  • @ChuckConway: Well said. – Jim G. Jun 20 '14 at 18:40
5

Upgrade as soon as you can without breaking anything. New functionalities, bug fix, new features are introduced in every iterations.

You might not need the latest features but when you do, you'll need to validate every new version in between what you have to make sure it doesn't break anything.

Small increment will allow you to keep everything up to date without having to upgrade 5 major releases and spend 5 hours testing everything at once.

4

Do you need any of the new features included in a newer version of JQuery? Does your site work as expected today?

If you answered "no" to the first and "yes" to the second question, then don't upgrade jQuery.

If you DO need new functionality, then you have to balance this against the cost of increased testing and possible introduction of new issues.

If you have issues with your current version of JQuery, then a newer version may have fixed your issue, but you still have an increased test burden because you have to ensure the new version doesn't break anything else.

This is why having a good suite of unit, functional and feature tests is so essential.

Richard Turner
  • 426
  • 2
  • 4
2

Only you can decide if the risks are worth it. Personally, I like to stay up to date. However, i have had a few bugs introduced when upgrading that broke something (or caused odd behavior). Since you have a year of development ahead of you, chances are it will have to go through a final QA anyways.

I say keep up to date. It's much easier to do continuous small integrations than large ones all at once.

Erik Funkenbusch
  • 2,768
  • 3
  • 22
  • 27
0

Test. Test, test, test, test, test.

I used jQuery UI version (then-current) on a project, and used an external plugin called .autocomplete that did type-ahead functionality, tying a text field to a JSON data source. Used it a LOT of places.

Then, months later, I needed to add a slider control that only came in a later-current version. Unfortunately, that later-current version added a native autocomplete function, which they claimed was the spiritual successor of the plugin I'd used, but which used entirely different methodology, functions, and data requirements, breaking the autocomplete fields on every page I used my new slider on.

Because the pages I was developing this new feature on didn't use autocompletes, I didn't notice. Because my client was in a rush to get this feature up before a trade show, it got rushed through staging and testing, and got into production with a crapton of broken autocompletes.

Ultimately, it was a failure of MY testing. And the lesson learned is, jQuery and jQuery UI have very little interest in backward compatibility. Which puts the requirement on us, as devs, to test and test and test.

Dan Ray
  • 9,106
  • 3
  • 37
  • 49
-1

In my experience, new versions of jQuery are generally more rigorous in their code cleanliness requirements regarding the calling code (your code).

There are numerous items that have been made deprecated ( http://api.jquery.com/category/deprecated/). There is no deprecated-since tag on the page, unfortunately. Older deprecations are more likely to break something.

Most notably (to me), the :checkbox selector and the toggle() function have been deprecated. Some time ago, this change has affected my own (oldest) jquery code. I did not this realize for a while.

On the other hand, newer jQuery releases usually come with substantial performance improvements. Check the changelogs, or maybe one of John Resig's presentations to see where the performance improvements were realized. If you would get any benefit from them... that's up to you to decide.

knb
  • 747
  • 1
  • 8
  • 16