0

I've read about the WP enqueue_script() function, but if I wanted to use a newer version of jQuery than what my WP installation is using, can I load it through this & WP will use the latest version? or will it load both? or what will happen?

Thanks!

  • Let me advise you that this is a bad idea. When we release WP, we test the scripts that ship with it to make sure they work. When jQuery 1.5 came out a while ago, a lot of sites broke because people were loading the "latest" version of jQuery from the Google API. WP wasn't tested with that version yet, and it killed a lot of the admin screen as a result. Just be aware of what can happen when you start overriding the tested parts of WordPress with your own stuff. – EAMann Mar 17 '11 at 17:27
2

To replace the default jQuery url, do:

wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'your custom url', ... );

Then call wp_enqueue_script( 'jquery' ); as usual.

Note that various pages in the WP admin might not be compatible with never versions of jQuery, not to mention plugin scripts.

| improve this answer | |
0

You can (de)register the builtin jquery with the following functions:

wp_deregister_script('jquery');

And register a new jquery library:

wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js', array(), '1.4', true);
| improve this answer | |
  • The stable is 1.5.1 already. :) Also for external script it is better to pass null for version - that will suppress version tag on output and improve caching aspects. – Rarst Mar 17 '11 at 22:39
  • The code example was a bit old ;). Thanks for the hint with the caching, I will look into this. – rofflox Mar 18 '11 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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