Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a script that is based on jQuery, so I'm not enqueue-ing jQuery directly, but via passing it in the array of dependent scripts:

 wp_enqueue_script("jquery-plugin-name",'http://hostname.il/blogname/wp-content/themes/twentyten/js/jquery-plugin-name.js', array('jquery'), '1');

This is loading jQuery v1.4.4, and it weighs 76kb, which seems very heavy, although the file looks compressed.

I have 2 questions:

  1. Is there I way in which I can make it load the latest version of jQuery?
  2. How can I make sure that the loaded file if minified?
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

That's the size of the minified jQuery nowadays :)

You can load the latest from Google:

wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"), false, '1.8.2');

Please keep in mind that this can cause issues moving forward, as you are forcing WordPress to load a certain version of WordPress instead of the version bundled with it. There are plugins out there that may be better suited for your needs, like WP JQuery Plus, which make sure to load the same version number as WordPress does, but with the benefit of loading it from Google.

share|improve this answer
    
Don't forget to conditionally exclude this from admin area, it uses jQuery a lot and doesn't like it swapped for another version. –  Rarst Jun 29 '11 at 10:46
    
Thanks. But how come this site has a much smaller jQuery file? –  Lea Cohen Jun 29 '11 at 10:57
    
It's older version. I wouldn't say it's much smaller, 10-15K? –  onetrickpony Jun 29 '11 at 11:02
    
@One, From what I see with JSView, the jQuery in WPSE is version 1.5.2 (mine is 1.4.4), and it weighs 29kb as opposed to my 76 kb. Thanks –  Lea Cohen Jun 29 '11 at 11:14
    
it's the same size, but the server probably serves it compressed –  onetrickpony Jun 29 '11 at 11:18
show 2 more comments

Do not modify the version of jQuery enqueued by WordPress.

Just don't do it. Core depends on a specific version. Themes and Plugins depend on a certain version. That certain version is the version bundled with a given version of WordPress.

If you need to perform script minification, compression, or concatenation, you can certainly do that (you can roll your own, or use a Plugin, such as W3 Total Cache, to do it for you.)

But as you can see: if you're got a 46kB file, you're already dealing with some combination of minification and compression.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.