We have had issues with Mootools not being very backward compatible specifically in the area of drag and drop functionality. I was wondering if anyone has had any similar problems with jQuery not being backward compatible. We are starting to use it quite heavily and are thinking about upgrading to a newer version to start using several plugins that require it. Will we have any issues if we get rid of the older version?
jQuery seems to be nicely backward compatible. I have been using it for more than a couple of years now through several versions of the core and have not had issues when upgrading except a few minor ones with some plugins. I would say that the core seems to be fine but if you're using a lot of plugins you might run into some problems (but these are usually easy to fix, or the new core has that functionality built in anyway so you can just drop them).
jQuery is so serious about backwards compatibility that they produce a "backwards compatibility" plugin for each release: http://docs.jquery.com/Release:jQuery_1.2#jQuery_1.1_Compatibility_Plugin. It let people who don't need backwards compatibility save on page weight.
My experience is that when upgrading, I sometimes find that stuff that used to work breaks. For instance, when upgrading from 1.7.2 to 1.8.3 I found some drag-and-drop features stopped working. Some problems may be due to deprecated jQuery functions being dropped, still in use by incompatible versions of jQuery UI.
Here is a quote from another user:
Backward compatibility may not be the jQuery team’s strong suit, but
as with most things, it’s a work in progress. I’m not meaning to
disparage the great work they do, but it points out the fact that you
simply must always test your scripts with new versions of jQuery.
jQuery has produced backwards compatibility plugins since version 1.0.
Web development has changed a lot over the years, and jQuery has changed along with it. Through all of this time, the team has tried to walk the line between maintaining compatibility with code from the past versus supporting the best web development practices of the present.
The project has the following backwards compatibility repos:
jquery-compat-1.0(Compatibility plugin for those upgrading to jQuery 1.1+ from jQuery 1.0)
jquery-compat-1.1(Compatibility plugin for those upgrading to jQuery 1.2+ from jQuery 1.1)
jquery-xpath(Implement XPath functionality for those upgrading to jQuery 1.2 from jQuery 1.1)
jquery-compat-1.3(Backwards compatibility plugin for jQuery 1.3 (to be used with jQuery 1.4))
jquery-migrate-1.x-stable(Migrate older jQuery code to jQuery 1.9+)
jquery-migrate(Migrate older jQuery code to jQuery 3.0+)
References
jQuery Blog
jQuery Wiki: Won't Fix
jQuery Core Upgrade Guides
jQuery Migrate Plugin - Warning Messages (2.0)
jQuery Migrate Plugin - Warning Messages (3.0)
jqLint
In my experience, jQuery 1.x has been very backwards-compatible until version 1.9.
The jQuery 1.x line had major changes as of jQuery 1.9.0. We strongly recommend that you also use the jQuery Migrate plugin if you are upgrading from pre-1.9 versions of jQuery or need to use plugins that haven't yet been updated. Read the jQuery 1.9 Upgrade Guide and the jQuery 1.9 release blog post for more information.
And don't upgrade to 2.0 until you're sure that this isn't an issue for you:
jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8.
Related
Just a conceptual question. Does the migrate plugin search through the javascript files pulled in by the browser? Or does the migrate plugin only look through code that is being executed by the server?
I need to use the jquery migrate plugin to update my code to the latest version of jquery. I'm trying to replace all instances of code stripped away in previous version and replace it with the latest ones.
From jQuery migrate docs:
Upgrading libraries such as jQuery can be a lot of work, when breaking changes have been introduced. jQuery Migrate makes this easier, by restoring the APIs that were removed, and additionally shows warnings in the browser console (development version of jQuery Migrate only) when removed and/or deprecated APIs are used.
That way you can spot and fix what otherwise would have been errors, until you no longer need jQuery Migrate and can remove it.
Does it look through your files? No. It only warns when deprecated methods have been called from within your code
We have multiple sites running on Jquery 1.11.0 and Jquery UI 1.10.4. To fix the vulnerability issues reported by Chrome Developer Audit report, we want to upgrade to the latest stable versions. As suggested by Audit report these are Jquery 3.x and Jquery UI 1.12.x.
Is there any safe way we can upgrade Jquery and Jquery UI also check for back compatibility, so that it will not break any existing UI.
The simplest answer is no, you would need to test it out on a test server to detect and eliminate any side effects/bugs.
However that said, jQuery has had good backward compatibility. I have been using it for more than a few years now through its many releases of the core and have not had any breaking issues.
jQuery has been proactive with backward compatibility that they actually produce a backward compatibility plugin for each release.
Here's a reference for an upgrade guide to Jquery 3.x. Ref Upgrade Guide to Jquery 3.x
I'm a bit stuck here. I have a website that currently uses jQuery 2.1.4 only. I just figured out it won't support older browsers such as IE 6, 7 and 8. I use jQuery for many things in my website, which includes login system, live chat and some management functions.
Anyway, I was thinking of implementing jQuery 1.11.3 because it supports these browsers. Thing is, I don't really know where to start from because I don't think I simply add another script source for jQuery 1.11.3 and it shall fix it all, but I'm looking for a way to add it so I won't have to change all my functions or add special functions just for older browsers.
The only jQuery methods I use are $.ajax, $.when and $.then.
I don't think I simply add another script source for jQuery 1.11.3 and it shall fix it all
You just replace the existing script source with it.
The 2.1.x branch is just the 1.11 branch with all the slow compatibility code for old browsers removed. They are API compatible.
I updated my jQuery from 1.3.2 to latest 2.1.0
Now I noticed I have this error on my page:
TypeError: Cannot read property 'safari' of undefined
And here is my code that has this:
if(p=='marginRight'&&$.browser.safari)
and
if($.browser.safari){this.buttons(false,false);
I read that from version 1.9 $.browser has been removed, can somebody please help, how can this be fixed? I googled and tried some things but didn't seem to find the right thing..
Thank you
you can detect browsers via native navigator object
if(navigator.userAgent.indexOf("Safari") > -1) {
// safari
}
The easiest way is to just include jquery-migrate. This patches in all the functions they removed.
Otherwise, you have to rewrite your code to avoid browser detection. Generally, feature detection is recommended over browser sniffing.
The jQuery.browser() method has been deprecated since jQuery 1.3 and
is removed in 1.9. If needed, it is available as part of the jQuery
Migrate plugin. We recommend using feature detection with a library
such as Modernizr.
Reference: http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed
Since it has been removed your most simple option here is to use jquery migrate
What happened is that we have a page that was previously working then all of sudden some scripts no longer work (for some reason). We figured out that we needed to use the latest jQuery library to fix the problem.
So we were thinking to just link to http://code.jquery.com/jquery-latest.min.js so that it's always updated.
However, we are also aware that if we will always use the latest jQuery library, the new version might cause some problems on other older scripts.
What is the best way to link the jQuery library then to minimize these types of issues?
Save the stable version of the library to your local/server and link to it. That's all.
It is a bad idea to link to http://code.jquery.com/jquery-latest.min.js
Jquery latest version always available in,
http://code.jquery.com/jquery-latest.js
For Latest Min Jquery, use
http://code.jquery.com/jquery-latest.min.js
To get latest jquery from other hosts, follow jquerylatest.com