开发者

How can I deal with outdated versions of jQuery on a client site?

I've already run into clients running 1.3 code, when my work relied on 1.4's much improved features.

Yet these clients don't have the resources to update their old code ...

Example: The client refers to jQuery 1.3 in their site's template, but I'd really rather use 1.4 for my code and not have to try and use the older version.

Any thoughts on开发者_高级运维 how to deal with this problem?

Edit: The ideal solution would be totally JS ... no server-side code as the client prefers it that way.


Try and make the clients aware that the "resources" needed are typically pretty light. Converting to a new version is usually a very quick process, unless they had a lot of erroneous code that was allowed before, but incorrect.

Have them take a look at the release notes for 1.4, and for that matter 1.4.1 and 1.4.2, the benefits of the upgrade far outweigh the time it takes to upgrade in every case I've come across. The only caveat to this is in the 1.4 upgrade specifically, the added JSON strictness. From the 1.4 release notes:

jQuery 1.3 and earlier used JavaScript’s eval to evaluate incoming JSON. jQuery 1.4 uses the native JSON parser if available. It also validates incoming JSON for validity, so malformed JSON (for instance {foo: "bar"}) will be rejected by jQuery in jQuery.getJSON and when specifying “json” as the dataType of an Ajax request.

This means JSON operations are much faster, but old/invalid JSON won't cut it. If they have to go fixing web-services because the JSON has to be absolutely valid in 1.4+, this could be a show-stopper on an upgrade for a large project...and I'm not sure what to tell you on that one.

As for plugins...every major/popular plugin supports new releases very quickly, if not they're pretty quick to fix yourself...and many just don't need any editing at all, because they weren't broken by the upgrade (still, check for new versions of a plugin, they may get performance boosts from a new version of core).


If you're asking whether two versions of jQuery can be embedded into the same document at the same time, the answer is no.

Your client would have to upgrade, which should be relatively easy to do - if they're lucky, without any work at all: See @Nick's excellent overview.

Alternatively, if you need to use jQuery 1.4 on some pages, and 1.3 on others, you would certainly be able to set up some server-side shenanigans to serve the correct version. (It would probably even be possible using JavaScript.) but to do that, you'd have to give us more info about the setup.


I am not sure I understand you question. Do you have a website that uses JQuery? Surely if you put the JQuery javascript files in a folder in your web app and reference them in your script tags then the users' browers will download the new libraries.

Can you please explain what you mean when you say

the clients don't have the resource to update their old code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜