Is it worth updating WP admin to jQuery 1.5?

The question:

I read that jQuery 1.5 has just been released.

Do you think that replacing version 1.4.2 with this new release is worth in terms of pure performance (on the admin side because my current theme does not use jQuery a lot)? Any side effects or compatibility problems?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Well, as for performance release post says:

In this release we’ve also been able
to improve the performance of some
commonly-used traversal methods:
.children(), .prev(), and .next(). The
speed-ups that we’re seeing are quite
substantial (potentially many many
times faster, depending upon the
browser).

On other hand replacing jQuery on admin side is rarely good idea, because it is getting merged into concatenated bunch of scripts and it’s a mess to deal with.

Unless you are suffering from considerable JS performance issues in admin, my personal opinion is that it isn’t worth the trouble.

PS WP 3.1 will have newer 1.4.4 jQuery version, don’t know if they will bother to bring it up to 1.5 by final release.

Update

WordPress 3.0.5 was released at the
same time as jQuery 1.5.
Unfortunately, 1.5 has some backwards
incompatible changes that appear to
break a number of areas in the admin.
The timing is awkward and it looks
like it was us. It wasn’t.

There’s nothing we can do about this even for WordPress 3.1, which is
freezing at jQuery 1.4.4.

( Andrew Nacin )

So issues t31os desribed are definitely caused by jQuery 1.5 and it is definitely not recommended to use in admin area at moment.

Method 2

Ticket linked to by hakre in comment to Rarst’s answer would indicate 3.2 should see the inclusion of jQuery 1.5, so you could simply wait until 3.2.

Alternatively, i did find a way to load 1.5 into the admin..

This works with or without concatenation on(just note the issues further down).

add_action( 'admin_init', 'try_jquery_version');
function try_jquery_version() {
    global $wp_scripts;
    if( !is_object( $wp_scripts ) )
        return;
    if( !isset( $wp_scripts->registered['jquery'] ) )
        return;
    $wp_scripts->registered['jquery']->src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js';
    $wp_scripts->registered['jquery']->ver = '1.5';
}

There are some side-effects, and i’m not sure if that’s the result of caching or whether other jQuery scripts have to also be updated inline with the new jQuery version(ie. ui-core), or whether it simply won’t work correctly in WordPress at present.

Known Issues:

  • Dashboards widgets don’t seem to load.
  • Various errors shown in Firefox’s console related to undefined vars and such(i don’t know enough about JS to know why these occur)

I’ll add any additional issues i see to the above.

For now, i’m going to keep testing 1.5 and see how i get on, it should be interesting to see if it makes a difference(seems a little faster, but it could just be me imagining it).

UPDATE: Feb 2nd 2011
As far as i can tell there’s nothing special that’s done to intergrate jquery into WordPress, having looked at the WP changesets, it looks as if jquery is simply updated as and when needed.

I currently assuming that the problems i’ve experienced are a natural result of changes in the new version of jquery or that i’m getting served up a cached version of the previous copy(or that ui needs updating inline with jquery to). I needed to get other things done, so i’ve switched back to 1.4(whatever is included in WP) for now and it doesn’t appear there was particular interest in my observations anyway(but happy to share my thoughts if anyone wants to hear them).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment