Use Google Libraries: A Plugin to Improve Script Loading Performance in WordPress

Please use the support forum if you need assistance.


A number of the javascript libraries distributed with WordPress are also
hosted on Google’s AJAX Libraries API.
This plugin allows your WordPress site to use the content distribution
network side of Google’s AJAX Library API, rather than serving these files from your WordPress install directly.

This provides numerous potential performance benefits:

  • increases the chance that a user already has these files cached
  • takes load off your server
  • uses compressed versions of the libraries (where available)
  • Google’s servers are set up to negotiate HTTP compression with the requesting browser

For a more detailed look see Dave Ward’s 3 reasons why you should let
Google host jQuery for

Supported Libraries and Components


Incompatible Plugins

Better WordPress Minify

Better WordPress Minify version 1.2.2 does not yet support
protocol-relative URLs, but the next release is supposed to correct

Gravity Forms

I’ve had reports of Gravity Forms breaking UGL, but I don’t have
access to Gravity Forms, so I’m not sure what’s going on. If you need
Gravity Forms you might need to disable UGL, or it might be fine, I’m
not really sure.


WP-Minify doesn’t yet support protocol-relative URLs. Add
‘//’ as a JS and CSS exclusion.

Incompatible Themes


I’ve had scattered reports that UGL is stepping out of the way when
using K2.

A Request

If you’re going to flag the plugin as “broken” in the WordPress Plugin
Directory, please try and let me know what is
I’m not a mind reader.

Technical Details

Use Google Libraries uses the following hooks (each with a priority of 1000).


Use Google Libraries compares it’s list of supported scripts to those
registered, and replaces the standard registrations src with ones that
point to Google’s servers. Other attributes (like dependencies) are left


Use Google Libraries removes the ver=x.y.z query string from the URL
used to load the requested library if it is going to load the library from Otherwise the URL is left unaltered. This both
improves the chances of the given URL already being cached, and prevents from including scripts multiple times.

If jQuery is enqued Use Google Libraries will inject a bit of
javascript before the next enqueued script enabling jQuery’s noConflict mode as it would
with the standard WordPress version.


Parts of this plugin (specificly, the dropping of the micro number,
which has since been removed for better caching performance) were
inspired by John Blackbourn’s
Google AJAX Libraries,
which has very similar goals to this plugin.

Future Plans

  • add ability to disable protocol relative URLs
  • add ability to disable on frontend and/or admin


Upload the use-google-libraries folder to the /wp-content/plugins/ folder.

Activate Use Google Libraries through the ‘Plugins’ menu in WordPress.

Er… That’s it really.


Q. Installation Instructions
A. Upload the use-google-libraries folder to the /wp-content/plugins/ folder.
Activate Use Google Libraries through the ‘Plugins’ menu in WordPress.
Er… That’s it really.

Q. What happens when Google updates their library versions?
A. Google has stated that they intend to keep every file they’ve hosted
available indefinitely, so you shouldn’t need to worry about them

Q. Why isn’t in doing anything?
A. Firstly, if you are using a caching plugin, flush the cache or
temporarily disable it to be sure it’s not doing anything. That said,
I’ve done my best to make Use Google Libraries gracefully step out
of the way when things are not as expected. While not, perhaps,
giving you the greatest benefit it helps ensure you site doesn’t just
flat out stop working.
In general, anything that calls wp_register_script and/or
wp_eneque_script before ‘init’ causes trouble for Use Google
. I’ve made an effort to force it to try and run anyhow,
so please report any issues with this. If you have ‘WP_DEBUG’
enabled, a message will be logged letting you know this is happening.
Please see the section on Incompatible Plugins and
Incompatible Themes for specific information.

Q. How do I use the libraries supplied by Use Google Libraries?
A. The same way you use them when Use Google Libraries isn’t installed using
‘wp_enqueue_script’. In fact you should develop your theme or plugin without
Use Google Libraries being enabled at all, then test it both ways.

Q. Why do some scripts continue to use the WordPress supplied versions?
A. Assuming some other plugin or theme isn’t the cause, Use Google Libries does
it’s very best to ensure your site behaves as it should when using the stock
WordPress scripts. If WordPress is asking for a version of a script that
Google isn’t hosting, then it will continue to use the WordPress supplied

Q. Can I always load the latest version of a hosted script?
A. No. Use Google Libraries doesn’t do that because it would almost certainly
break WordPress. Even if it didn’t, the less ‘version specific’ URLs supported
by Google’s CDN set a short term ‘Expires’ header, so there wouldn’t be much


  • Updated supported version.
  • used to get around link that’s now malware

  • Bypass functionality when running under 4.2+ until next version to avoid breaking sites.


  • added some missing jQuery UI modules (hopefully fixes issues from support
    forums I couldn’t reproduce previously).


  • same as 1.6 (due to SVN issue with 1.6)


  • Drop support for PHP4, and WordPress < 3.4
  • clean up PHP 5.x strict issues


  • using protocol-relative URLS with WordPress >= 3.5
  • use WordPress provided is_ssl rather than custom check (only for
    WordPress < 3.5)
  • Detect if ‘jquery’ is a meta-script registration, and actual jQuery
    is loaded as ‘jquery-core’ tag (WordPress 3.6 Beta).


  • fix bug in is_ssl check.


  • using wp_remote_head to query that the replacement URL is actually
    hosted by google. If it’s not, then the WordPress supplied version will be
  • Using the Transient API to store the replacement URLS, rather than
    recalculating and re-querying them every load.


  • Added check for WordPress including non-standard versions of scripts (fixes
    WordPress 3.2.2/swfobject).
  • Fixed incorrect case in HTTPS check.


  • Reworked handling for cases where multiple js files are combined
    into one on Google’s servers. In the past this has been mostly a
    non-issue because the dependencies took care of it, but due to changes
    in the latest jQuery UI this stopped working as expected.


  • Updated jQuery UI to work with WordPress 3.1rc1

  • Re-disable script concatenation. Seemed to break widget admin page.


  • No longer disable script concatenation when using WordPress 3.0 or
  • Attempt to detect when another plugin or theme has called
    ‘wp_register_script’ and/or ‘wp_enque_script’ before ‘init’ and work
    around it.
  • Limited debugging output when WP_DEBUG is enabled.

  • Hopefully fix issue with plugin loading for some users

  • Added Incompatible Plugins and Incompatible Themes sections
    to the README


  • more https detection
  • inline jQuery.noConflict()

  • fix previous fix (whoops!)


  • moved location of the Changelog section in the README


  • Disables script concatenation in WordPress 2.8, since it seems to have
    issues when some of the dependencies are outside of the concatenation.
  • Persists flag to load scripts in the footer in WordPress 2.8


  • It should detect when a page is loaded over https and load the libraries over https accordingly
  • It no longer drops the micro version number from the url. The reasons for this are twofold:
    • It ensures the version requested is the version received.
    • Google’s servers set the expires header for 12 months for these
      urls, as opposed to 1 hour. This allows clients to cache the file
      for up to a year without needing to retrieve it again from Google’s
      servers. If the version requested by your WordPress install
      changes, so will the URL so there’s no worry that you’ll keep
      loading an old version.

194 thoughts on “Use Google Libraries: A Plugin to Improve Script Loading Performance in WordPress”

  1. Hi Jason,

    Nice work on this plugin. I never got round to updating my plugin to handle the various sub-libraries, and now you’ve done the hard work for me :) I’ll point everyone to your plugin in the future.


  2. Pingback:
  3. Jason,
    I was thinking to myself the other day if this would be possible, luckily before I tried writing it myself I did a search and saw it’d already been done.
    Unfortunately I can’t seem to get it to work and I’m not sure why. I cleared out my cache and refreshed the page just to make sure, but every time it’s pulling from the WordPress directory and not Google. I even switched off the K2 “theme” just to make sure that wasn’t causing a conflict.
    I’m using WP 2.7.

    Any ideas?


  4. @malcalevak – Sorry for the delay in reply. I can’t think of any reason why it wouldn’t be working for you. Are you using wp-cache or wp-super-cache? You didn’t leave a link so I can’t check which of the supported libraries are being loaded on your site, but I’d be glad to help you figure it out.

  5. @Jason Penney – Jason, Thanks for getting back to me. I thought I’d left a link, but it seems I was mistaken. I’ve attached one now.
    I’ve attempted to use wp-cache and wp-super-cache, but wasn’t actually able to get them to work right, so I turned them off, and they were not on when I actually reported the problem.
    Would it be possible that the K2 theme (which uses jQuery) is somehow overriding what’s being done by the plugin? (This seems doubtful, but worth mentioning).

  6. @malcalevak – I took a quick look through K2’s source, and I think you might be on to something. If I’m reading it correctly K2 will call wp_register_script on jQuery some time after wp_default_scripts fires.

    This is the expected behavior of my plugin, because I wanted to be sure that if a theme or other plugin was re-registering one of the default scripts for a good reason (like they came with a customized version, etc) my plugin would gracefully step out of the way.

    You could try going into [k2-theme-dir]/app/classes/k2.php and comment out the following lines in register_scripts() (starting on line 198 in K2 1.0rc7):

    false, ‘1.2.6’);

  7. Hello,

    Thanks for the plugin, could I make a couple of suggestions:

    1) Revert to using the micro version, say jquery 1.2.6, as the google servers will instruct browsers to cache for 12 months, using 1.2 the cache is set to 1 hour.

    2) check if the wordpress site is being loaded over SSL and load the library over SSL if reqd, a simple way to do this could be to change

    if ($lib != '') {
    // build new URL
    $script->src = "$lib/$ver/$js.js";
    } else {


    if ((isset($_SERVER['HTTPS'])) AND ($_SERVER['HTTPS'] != '') AND ($_SERVER['HTTPS'] != 'off')) {
    //use ssl
    $gP = 'https://';
    } else {
    //dont use ssl
    $gP = 'http://';
    if ($lib != '') {
    // build new URL
    $script->src = $gP . "$lib/$ver/$js.js";
    } else {

  8. @malcalevak – I’m out of ideas at the moment. My plugin is doing what I expect (letting K2 override jQuery to it’s own version), although I’m not sure it needs to be.

    @Peter Wilson – Thank you very much for the suggestions. I’ll try and get those worked into the next update. I’ll probably make the micro version an option, and add an explanation of why you would want to include it.

  9. I’ve been working on an upcoming blog project and in testing your plugin I’ve failed to see any result of having it installed. I’m currently using a number of plugins which make .js calls in the header, such as Lightbox 2. When I run a test using YSlow, I see that all of the original, local .js versions are still being reference in the code…rather than linking to those hosted by Google. I’ve re-read the Installation instructions, FAQ and Other Notes and can’t imagine that I’ve done anything wrong…it’s installed and activated. Am I missing something here?

    Thanks in advance,

  10. @CR – My initial guess is that these other plugins are not using the WordPress API to include their scripts, but are injecting them into the header directly. Without more to go on it’s a bit tricky, but if you leave links to the plugins you’re using I’ll take a peek.

  11. Originally Posted By Jason Penney@malcalevak – I’m out of ideas at the moment. My plugin is doing what I expect (letting K2 override jQuery to it’s own version), although I’m not sure it needs to be.

    Jason, I just wanted to point out that K2 doesn’t override the WordPress jQuery at all. As can be seen on the site I provided, which is running the nightly revision 743 of K2, it is using the WP provided copies of jQuery, and only running it’s own copies of scripts not included with WP. It has register calls for all the scripts, but WP apparently ignores them if they’re already registered. I don’t know if that will help diagnose the issue or not.

  12. Hey, Jason great to have found you.
    I am wondering how I can use this plugin in conjunction with the various plugins I’ve recently made. They all use mootools, and I have had trouble getting the register and enqueue script functions to work. So for now I’m loading into head. I guess my question is , will this plugin pull the mootools from, or google? Well, I’ll see if I can get the enqueue working for me, then do some testing. Thanx for the plugin and great idea.

  13. Originally Posted By Jason Penney@twincascos – What issues are you having with enqueue? All you should need to do is wp_enqueue_script('mootools')

    Sounds easy doesn’t it? But actually, First I have to register the script in my init function.wp_register_script(
    path_join( WP_PLUGIN_DIR, basename( dirname( __FILE__ ) ) . '/js/mootools-1.2.1-core.js' ),NULL, '1.2.1');

    path_join( WP_PLUGIN_DIR, basename( dirname( __FILE__ ) ) . '/js/mootools-1.2-more.js' ), array( 'moocore' ), '1.2');

    Then I register the action which would load the script: add_action('wp_print_scripts', array(&$this,'add_javascript'),3);
    And now I can enqueue the script:wp_enqueue_script('moocore');

    Wow, this finally works for me. now to test it out with more than one plugin.
    And to see if your google library plugin works with mootools base then the more libs.

  14. It is showing some errors while installation. As the download completes there shows a box, it was written over there that “downloading process is under construction currently. The plugin doesn’t support the version.”, I just don’t understand what kindda msg it was. Need assistance.

  15. @gammon team – I’m not sure what you’re talking about, but if you provide more details about what it is you’re doing, I’ll try and help.

    @ovidiu – The two plugins are pretty similar. At the end of the day use what works best for you.

    • This plugin hooks different functionality to ensure that the google urls are inserted immediately after the core urls, in case some other plugin relies on being able to override them.
    • The next version will be changing to use the exact version in the URL (by default) since, as Peter Wilson pointed out above, that should allow the files to be cached much longer on the client systems.
    • this plugin is under the GPL.
    • this plugin sets jQuery.noConflict from a static file
    • this plugin sets jQuery.noConflict any time jQuery is included (not just when prototype is also loaded), as that’s what the WordPress core jQuery does (to the best of my understanding)

    I can’t say any of those would be a good reason to switch if you’re using the other one and it works for you. Good luck!

  16. Hi, how can I select which version of jQuery is loaded with this plugin?… No mather what I do, it always load version 1.2 …

  17. @Joao Amado – Currently if you ask for any 1.2.x it will load the latest 1.2 (which is 1.2.6). If you ask for 1.3.x it will load 1.3.2, etc. I’ll be changing it to load the exact version requested, as Google has the exact versions set up to cache longer.

  18. @Jason Penney – Ok! But how can I ask to load 1.3.x? I’ve tried to do so on enqueing or registering jQuery, but to no success… most probably it’s something I’m doing wrong.

  19. @Joao Amado – Ah, I see. In this case my plugin doesn’t really enter into it, because you want to replace one of the default script registrations. This should do it:wp_deregister_script('jquery');

  20. Hi Jason

    Great plugin – got it installed.

    However, my knowledge of JS and so on is nil – how can I tell if this plugin is working. I’ve run some elementary speed tests and I believe I saw a marginal improvement in the speed of serving JS but I would like a little more definitive proof – this is just a learning curve thing for me.

    Many thanks and keep up the excellent work!


  21. @Jason Penney

    It’s been a while since I last contacted you, but am back to try and figure out why A) my site is calling 17 external .js files that should be covered by your plugin and B) which other plugins I’m currently using that are not utilizing the proper code to take advantage of your plugin.

    I’ve isolated “Flexi Quote Rotator” as one possible culprit. It uses the following:
    echo "<script src=\"" . get_settings('siteurl') . "/wp-includes/js/scriptaculous/prototype.js\" type=\"text/javascript\"></script>\n";
    echo "<script src=\"" . get_settings('siteurl') . "/wp-includes/js/scriptaculous/scriptaculous.js\" type=\"text/javascript\"></script>\n";
    echo "<script src=\"" . get_settings('siteurl') . "/wp-includes/js/scriptaculous/effects.js\" type=\"text/javascript\"><>/script>\n";<

    I’m assuming this isn’t the proper WordPress API syntax(?) that you mentioned. As it were, how would I modify this above code to take advantage of the WP API and your plugin?

    These seem to be the 17 repeat culprits on every page…even pages that don’t have any content yet, seriously. I will say that they match almost precisely the calls within /wp-incudes/script-loader.php:


    And here are a list of the plugins I’m using…pretty lean:
    1) cforms
    2) Exclude Pages from Navigation
    3) Flexi Quote Rotator
    4) Lightbox 2
    5) Roll Manager
    6) Shockingly Big IE6 Warning
    7) Use Google Libraries

    Of these, I know that:
    1) cforms calls a few .js files, mostly specific to the plugin. can employ jquery, but I’ve turned it off.
    2) Exclude Pages makes no .js calls
    3) Flexi Quote calls the three listed above
    4) Lightbox 2 calls only lightbox.js, so no worries there
    5) Roll Manager makes no .js calls
    6) Shockingly Big links to its own included jquery.js file
    7) n/a

    Alright, hope this helps give you an idea of what I’m up against and which way to go from here. Thank you in advance for any help you can offer…hope my lingo is decent enough to follow.

    I think I corrected your code section above –Jay

  22. @BillyB – You can always view source on your page, and see what url the js files are being loaded from.

    @CR – You’re right. That code is hard inserting the js into the header, rather than using the API. There’s no chance to intercept it (and if another plugin WAS using the API, you’d be including those files twice). Because of the way it works it’s not a simple change, but I’ll take a crack at it and let you know.

  23. @CR – Ok, here’s a quick and dirty version:

    in flexi-quote-rotator.php find:
    add_shortcode('quoteRotator', 'quoteRotator_func');
    insert a new line under it:

    in quote-rotator-class.php comment out the three echo lines mentioned above. Then just before:
    function addHeaderContent()
    insert function enqueueScripts()

    Not sure if they’ll see it, but I filed an enhancement request with a patch.

  24. @Jason Penney

    Wow, thanks for your time and help on this. I’ve not yet replaced the code, but will be doing so tonight and will update accordingly. Just wanted to mention, also, that the issue tracker for WP was unknown to me and it’s so cool that you’re able to communicate with other developers on that level. I wonder if the same can be done with regard to cforms, though the guy isn’t listed in WP’s repository and I remember reading why at one point…just can’t remember. It’s a great plugin, but damn does it bring the clutter. :-) Anyway, thanks again and I’ll update you soon!

  25. @CR

    I thought I’d replied with a second follow-up, guess I didn’t hit ‘submit’. You’re definitely my hero of the month…this totally fixed the issues with ‘Flexi’ and has greatly improved my site’s load time (and Yslow rating). Many thanks to you for your time and knowledge. I thought before that Lighbox 2 ( was only calling lightbox.js, but it’s calling Scriptaculous and Prototype also. I wrote the author, who replied with a “thanks for the heads up”, but said he’d not been actively programming for quite some time and didn’t mention that he might include it in a future release. So, in that regard I also want to thank you for the attention you’ve paid my concerns. If everyone just had a billion other moments like you…lol. I’m going to try and learn from what info you provided me re:Flexi to try and fix Lightbox 2 and Shockingly Big IE6 Warning…should be interesting! :-)

  26. I’m using this plugin with the new P2 theme from Automattic. But it doesn’t seems to work.

    In p2/functions.php there is this line:

    wp_enqueue_script( 'p2js', get_bloginfo('template_directory' ).'/inc/p2.js', array( 'jquery' ), '200903301' );

    And in the generated source I see this

    <script type='text/javascript' src=''></script>

    Is there something wrong with P2 or with this plugin?


  27. @Kia – I’ve tried using Clearskys Google Ajax Libraries Api Plugin. That solve the problem.

    I’d prefer using your plugin. Would it be possible to fix this issue? Your plugin seems more stable, and can handle versions better that Clearskys.

  28. @Kia – OK, I just tried a test site with WordPress 2.8-bleeding-edge, P2 1.0.3, and Use Google Libraries 1.0.5 and here’s what I’m seeing:

    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src='http://XXXXXXX/wp-content/plugins/use-google-libraries/js/jQnc.js?ver=2.8-bleeding-edge'></script>
    <script type='text/javascript' src='http://XXXXXXX/wp-includes/js/comment-reply.js?ver=20090102'></script>

    Do you have any other plugins activated?

  29. Originally Posted By Jason Penney@Kia – OK, I just tried a test site with WordPress 2.8-bleeding-edge, P2 1.0.3, and Use Google Libraries 1.0.5 and here’s what I’m seeing:

    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src=''></script>
    <script type='text/javascript' src='http://XXXXXXX/wp-content/plugins/use-google-libraries/js/jQnc.js?ver=2.8-bleeding-edge'></script>
    <script type='text/javascript' src='http://XXXXXXX/wp-includes/js/comment-reply.js?ver=20090102'></script>

    Do you have any other plugins activated?

    Yes. I’ve now located the problem:

    I’m not sure why. But when activated, your plugin doesn’t work. Strange…

  30. Originally Posted By Kia
    Yes. I’ve now located the problem:

    I’m not sure why. But when activated, your plugin doesn’t work. Strange…

    It appears that Author Avatars is re-registering jquery-ui-resizable on lib/AuthorAvatars.class.php line 67. My plugin, as designed, steps out of the way at this point. Still, I’m not sure Author Avatars needs to do this. You can try commenting that line out, and see if things work.

    If that works you may wish to contact the plugin author and ask if they could check if jquery-ui-resizeable is already registered first (using $wp_scripts->query('jquery-ui-resizeable')).

    Good luck!

  31. Hey, nice plugin… great idea! :)

    It appears that Author Avatars is re-registering jquery-ui-resizable on lib/AuthorAvatars.class.php line 67. My plugin, as designed, steps out of the way at this point. Still, I’m not sure Author Avatars needs to do this. You can try commenting that line out, and see if things work.

    If that works you may wish to contact the plugin author and ask if they could check if jquery-ui-resizeable is already registered first (using $wp_scripts->query(‘jquery-ui-resizeable’)).

    I added “jquery-ui-resizable” for wordpress 2.6 which didn’t have it included in the core (if I remember correctly). As someone in an earlier comment already mentioned: re-registering scripts does not have an effect if the script already exists. (The actual checking for already existing scripts is done in WP_Dependencies::add(); see So if your plugin only changes the “defaults” (but keeps them all in the list) then me re-registering something then that shouldn’t really have an effect, right?

    I am not sure what’s happening here exactly but I’m open for suggestions and willing to change the Author Avatars List plugin if necessary…

  32. I think that the IntenseDebate plugin conflicts. With both the IntenseDebate and Use Google Libraries plugins enabled I see the wp-includes JS files, but if I disable IntenseDebate the files switch to the Google APIs files.

  33. @yoyo – The plugin is working in 2.8 fine, but it doesn’t have support for the extra data (like the flag that says to load in the footer) in the released version.

    I’ve added it, but I have to set up a 2.7 install to test that it still works there. Feel free to grab this version and see if it does what you want until then.

  34. Seems to be a conflict /w 1.05 & the About Me 1.03 plugin in WordPress 2.8-final. Cannot retain changes to posts/pages. (i.e. make a change on a blog post, click “Update post”, and page refreshes but changes are not applied.)

  35. I love the idea of this plugin, but it isn’t working for me, my scripts are still the local versions. The mysterious part is that the limited number of plugins I am using do not touch jquery at all (a case-insensitive search on my plugins directory for “jquery” came up empty). Would the fact that my blog is not currently online, but being tested on a local server, be the culprit? I cannot imagine why since if I hard-code in the Google script, it works fine. I am using the built-in WP enqueuing function.

  36. @Gabriel – PS, no link because as I mentioned the site is currently on a local server only. FYI, my code looks like this: wp_enqueue_script('commonjs', '/wp-content/themes/phantoms/js/commonjs.js', array('jquery'));

  37. I think there is a conflict with the StatPress plugin. It is a very popular plugin I use that shows page views and visitors, and other info. Idk if it still works, but I do know that when both your plugin and StatPress are activated I can no longer get to the StatPress admin pages. They time out. Could you release a fix for this please? Thank you!

    Great plugin!

  38. @Jason Penney – Thanks for replying so quickly. I can tell from the history of this comment thread that you’re dedicated to making this plugin work if you can. Unfortunately I don’t have much else in the way of clues for you to work on…

    I don’t use any caching plugin, and I cleared my browser cache (and tried it in different browsers too). The code I referenced is a line in my theme’s header.php file, in the normal location before wp_head() (it works as expected without your plugin). Is there somewhere else I should try putting it? I may break up the javascript call into a separate script registration and then wp_enqueue; I cannot imagine why that would help and it is less elegant than using the one-line API, but who knows. At least it’s something to try, right?

  39. I commented several days ago, but it seems that comment didn’t pass some plugin because of several links in it. So I’m trying again.

  40. Quick questions: why it needs to insert code for noConflict, I don’t see that this is loaded regularly from WordPress directory nor that this code is somewhere in page’s source code?

    If this code is needed, why you are placing it in separate file? Can’t you simple include it in head or footer of page? With situation like this you are adding additional request and you should know that you should have as least requests as possible, because of page loading and because of server performance. Read more about it here.

    Headers sent and received for this file are much more larger then file itself! Look this report from test I’ve done for this page. File is 40 bytes, and just sent headers are 0.5 KB, plus received headers of around 0.4 KB, it’s almost completely unnecessarily 1 KB, and on other sites they could be even larger (because of cookies and other things that browser and server could include in it).

    So you shouldn’t noConflict code from separate file, simply place it in page itself.

  41. Have a problem with the plugin. I’m using WP 2.8.2 and I can’t add tags when the plugin is enabled. So I have to disable it everytime I add tags.. then re-enable it…
    Any ideas on how this could be fixed?

  42. Originally Posted By Milan
    Quick questions: why it needs to insert code for noConflict, I don’t see that this is loaded regularly from WordPress directory nor that this code is somewhere in page’s source code?

    Unfortunately there’s no way for me to do what you require using the WordPress script loading API (at least that I’m aware of). In order to ensure that using my plug-in is as close an experience to using stock WordPress I have to insert the noconflict directly after jQuery itself. The jQuery included in WordPress (at least at the time of my starting this plug-in) was modified to add that noConflict line.

    I’ll try and verify if it’s still needed in 2.8 or not though. If not I’ll drop it conditionally.

  43. Originally Posted By Gabriel
    @Jason Penney – The code I referenced is a line in my theme’s header.php file, in the normal location before wp_head() (it works as expected without your plugin). Is there somewhere else I should try putting it?

    Sorry for the delay in response. So you mean the call is directly in your theme, not inside any hook or anything?


    Can you try something like this? In your themes ‘functions.php’ (if you don’t have one, just make one):
    function mytheme_init() {
    $myscript = '/js/commonjs.js'
    wp_enqueue_script('commonjs', get_bloginfo('template_url').$myscript, array('jquery'));

  44. Thank you for your answer and clarification. I wasn’t aware that they changed jQuery file, I thought that it is identical as one from jQuery repository or from Google’s servers.

    I researched farther and found that noconflict is needed for Prototype. Is there need for other libraries too? Following this I found that in other plugin that stopped developing, there is a code that checks if Prototype is loaded and only in that case calls JavaScript file with noconflict. I tested this and it really works like described.

    Maybe you could try to implement that so at least that external file is not loaded all the time. Also we could ask on wp-hackers mailing list for solution to add that code in page itself, maybe it is possible.

  45. Thanks for the plugin. I noticed wordpress still loads ui.core.js and ui.tabs.js locally.
    Is this because of the wp-includes/script-loader.php? Is there a way to get these loaded external too?

  46. @Milan – I think noConflict can come into play with some other libraries (non-WordPress standard, but I don’t want to assume anything). At a minimum I’ll see if I can add a setting to not load it as an option. I’ve thrown out some feelers on wp-hackers for other issues, but I must be doing something wrong because I’ve never gotten a response.

    @Joep Hein – Something changed since 2.8 that’s preventing UGL from doing anything on the admin pages. I’ll investigate. It should still be doing the right thing on the front end.

    @Jon – I’ve got newer SSL detection code in trunk, but I didn’t catch that one! Thanks! I wish I knew how to get a category set up on the WordPress Plugin trac server so folks could file bugs/patches.

  47. Installed the plugin and looking at the page source i see

    script type=’text/javascript’ src=’’>
    script type=’text/javascript’ src=’′>

    The first script source is what I was expecting. What is the second (use-google-libraries/js…)?

    Just curious really, everything seems to be working correctly.

    Thanks for awesome plugin!

  48. Hey Jason, I’m sure it took you a while to figure this all out. I have created several plugins in the past, and never had a problem with load time. Under what circumstances can load time before so compromised that is worth spending time figuring out exactly how to make the changes you have suggested here.

  49. Hi,

    this is a great plugin! Thanks!
    But unfortunately i am to stupid to include things the right way and can’t get anything to work. I wanted to implement a tabs in my sidebar and don’t have any idea how to include the scripts now. Could you help me out here? I tried the local js-Files but i’m doing something wrong here…

  50. Hi,

    Great plugin! Have you been thinking about adding the rest of the libraries (especially SWFObject), which are these days available from Google Libraries?

    1. Thanks. I’ve been planning to add the remaining libraries that are available, as well as a handful of other improvements as soon as I can find the time. Glad you’re finding it useful!

      1. I think that SWFObject is already included, though it is not included in lists on this page or on description on

        Do you plan to include suggestion I wrote here (which didn’t pass spam test) which I got from wp-hackers about inline no.conflict code? Tynan Colin Beatty sent code a month ago and I still didn’t reply to him since you didn’t reply to me :(

        1. I’ll have to double check. I think i ‘future proofed’ SWFObject (so if WordPress Core started including it UGL would grab the one from Google). I apologize about not responding. I thought I had. If you have some code I can use for the noconflict issue please let me know.

          It seems the spam-filter issue is fixed at least.

          1. I wrote a comment here about a month ago with this, maybe it is in your spam queue or something like that.

            Point is that I asked on wp-hackers and got one response with some code example. See it here.

  51. Is this plugin supposed to work with wp_enqueue_script? It doesn’t appear to be for me and the Other notes in the WordPress plugin directory doesn’t mention the function. Yet it’s my understanding that wp_enqueue_script is the preferred way to load scripts in WordPress. Am I missing something?

    1. That’s all this plugin does. If you call wp_enqueue_script('jquery'); in you theme or plugin then it should pull it from the Google Libraries CDN instead of from your local version once the plugin is activated.

      What exactly are you trying to do that isn’t working?

      1. On WordPress 2.8.4 with Use Google Libraries, I’ve been trying to get jquery-ui-core to load on my author pages. I’ve tried a couple variations on using wp_enqueue_script but the page source shows I keep getting the copy of jquery-ui-core installed with WordPress. The last thing I tried was putting this bit of code in my header file, above wp_head():
        <?php if ( is_author() ) wp_enqueue_script( 'jquery-ui-core' ); ?>

        fixed your code — Jay

        1. I’m guessing it’s one of two things.

          You may need to do that at the init hook. So in your theme’s functions.php you could add:

          function my_init() {
          if ( is_author() ) wp_enqueue_script( 'jquery-ui-core' );


          It’s also possible another plugin is getting in there and insisting on the local version, or something changed in WordPress core in 2.8.3+ that I need to take into account. Are you running any other plugins?

          1. Tried that and it didn’t appear to work for me, but I did find a work around that does. I do use a considerable number of plugins, so it’s possible something in one of them is causing the problem. Are there any specific plugins you know of that interact badly with Use Google Libraries?

  52. on my site, enabling this doesn’t seem to do anything as far as i can tell. firebug is still telling me that all of the scripts are being loaded from the site’s domain as opposed to remotely from the google url.

    anyone have a trick to getting this to work?

    1. Maybe this is happening because there is some plugin that is in conflict with this one. For example, I found that when plugin Delink Comment Author is activated, scripts are loaded from blog’s server, not from Google’s.

      BTW, you can check from where your scripts are loaded by viewing source code of page (press CTRL + U or go to View → Page Source). If there is domain, it means that Google’s server is used.

      1. I have been using FireBug to trouble shoot this (and a few other issues) and the javascript files are most definitely not being loaded from the google api’s site.

        With that said, I do have a billion other wordpress plugins installed, but not the one that you mention (delink). Will keep looking into it, but don’t really know where to start as far as troubleshooting where things are going wrong.

  53. I just installed this in WordPress 2.8.6 using the Thematic theme, and activated it, but it doesn’t appear to be doing anything, WordPress is still using its own local jquery libraries.

  54. I was running into the same issue as everyone else looking for help. I successfully installed the plugin, and I was even able to see jQuery in the header, but no response from my scripts. I was even able to manually load into my header and successfully achieve the desired result.

    When all was said and done my fix is as follows. I had manually loaded fancybox, easyslider, and coda button into my header. Yes I know there’s plugins available for each of those scripts, but the plugins load up to much junk, and I’m building something a little more streamlined and responsive. I put each of the scripts into “noconflict”, even fancybox, dropped them below wp_head, removed the jQuery script which I had manually put in. And wallah, it worked as it should. No additional jQuery scripts, and no wp_enqueue_script. After that I compressed my scripts, and with jQuery now loading as it should from Google, my load times have improved significantly.

    I’m sure part of my issue was related to conflicting scripts, but the main issue seemed to be that my scripts were loading before jQuery. If your problem sounds similar, have a look at whats loading first. Always the simple fix. Good luck folks.

  55. Somehow, the LightBox 2 plugin conflicts with this one. I just verified this with a mass plugin-deactivation and subsequent one-by-one activation.

  56. PROBLEM: I just updated your plugin to and my blog is having major problems at –

    Some errors:
    Warning: call_user_func_array() []: Unable to call JCP_UseGoogleLibraries::setup_filter() in /home/.renaissance/talim/ on line 339

    Warning: call_user_func_array() []: Unable to call JCP_UseGoogleLibraries::replace_default_scripts_action() in /home/.renaissance/talim/ on line 414

    Warning: call_user_func_array() []: Unable to call JCP_UseGoogleLibraries::remove_ver_query_filter() in /home/.renaissance/talim/ on line 166

    I am using the latest Thesis theme 1.6 and the latest WordPress version.

    Please help or at least point me to the next immediate older version of the plugin.


    1. i’d just like to confirm that i am to having the problem with call_user_func_array() []: Unable to call JCP_UseGoogleLibraries::setup_filter(), also on php5. i wish i could get you more details why this is happening, but i am myself at a loss.

  57. It looks like the latest version is breaking some features in the WordPress admin e.g. quick edit for posts, the edit button no the post page to change the slug.

    Reverting back to 1.0.7 fixes the problem so that’s what I did.

    Using WordPress 2.9.1.

    Otherwise great plugin!

  58. Is there any way to get this script to grab the most recent version of a library, rather than whatever version is currently installed with WordPress?

    For example, Google has jQuery version 1.4.2, but it’s getting version 1.3.2. I’d rather grab the most recent version.

  59. Hi Jason,

    I’m having trouble getting this plugin to work with WordPress System Health ( which uses the jquery-ui-tabs code, which doesn’t seem to get loaded when using your plugin.

    Before loading the System Health Plugin, the source for wp-admin/load-scripts.php is:

    <script type='text/javascript' src=',common,jquery-color,wp-ajax-response,wp-lists,jquery-ui-core,jquery-ui-resizable,admin-comments,jquery-ui-sortable,postbox,dashboard,plugin-install,thickbox,media-upload&ver=e7dd2696b99d6664702753286996fc2d'></script>

    After, the line is:

    <script type='text/javascript' src=',common,jquery-color,jquery-ui-core,jquery-ui-tabs,wp-ajax-response,wp-lists,jquery-ui-resizable,admin-comments,jquery-ui-sortable,postbox,dashboard,plugin-install,thickbox,media-upload&ver=653d06ff789ad97dd5d62971c58c0cca'></script>

    WordPress System Health loads most of it’s hooks at 99999, which includes the wp_enqueue_scripts for jquery-ui-tabs, but as soon as I turn UGL on, the jquery-ui-tabs code doesn’t appear anywhere in the page source.

    Any ideas how I can make this work?


    1. UGL disables script concatenation since it causes issues in cases where the files on google contain the same contents as multiple files in WP. Concatenation is active in your “after” snippet. Did you do something to force it back on?

      1. Unless WP System Health does it internally, no — they’re the only two plugins installed on that test installation (Akismet & the test plugin are disabled).

      2. From the WP System Health “WordPress” tab without UGL turned on (so it’s the only activated plugin)

        Journal Database Requests
        (SAVEQUERIES) Off
        Whether to enable journal of database queries performed.

        Concatinate Javascripts
        Whether to enable concatination of all enqueued Javascripts into one single file for serving.

        Compress Javascripts
        Whether to enable compression of Javascripts being served.

        Compress Stylesheets
        (COMPRESS_CSS) Off
        Whether to enable compression of Stylesheet files being served.

        Enforce GZip Compression
        (ENFORCE_GZIP) Off
        Whether to force GZip instead of Inflate if compression is enabled.

      3. A further update:

        WP System Health has the following code:

        if ($active_plugins[0] != $this->plugin_basename) {
        // force at least at next page load this plugin to be the first one loaded to show up the
        // other plugins memory consume
        $reorder[] = $this->plugin_basename;
        foreach($active_plugins as $plugin) {
        if ($plugin != $this->plugin_basename)
        $reorder[] = $plugin;
        update_option('active_plugins', $reorder);

        So, I commented out the update_option line, cleared the browser cache, logged out, logged in and the plugin still seemed to work.

        The load-scripts line looked like:

        <script type='text/javascript' src=',common,jquery-color,jquery-ui-core,jquery-ui-tabs,wp-ajax-response,wp-lists,jquery-ui-resizable,admin-comments,jquery-ui-sortable,postbox,dashboard,plugin-install,thickbox,media-upload&ver=653d06ff789ad97dd5d62971c58c0cca'></script>

        Then I re-added UGL, which made the javascript load without the concatenation, so in the footer — I have:

        <script type='text/javascript' src=''></script<
        <script type='text/javascript' src=''></script>
        <script type='text/javascript' src=''></script>

        So, still no jquery-tabs.

        Finally, I went hunting the WP Codex for other things that might affect the concatenation and found the CONCATENATE_SCRIPTS variable — & found if I use:

        define('CONCATENATE_SCRIPTS', false);

        In wp-config.php, everything works as expected.

        Would it be wise to just leave that there until an alternative solution can be found?

      4. Oops, spoke too soon.

        If I use the define(‘CONCATENATE_SCRIPTS’, false); without UGL, (and an unaltered copy of WP System Health), the footer looks like:

        <script type='text/javascript' src=''></script>
        <script type='text/javascript' src=''></script>
        <script type='text/javascript' src=''></script>
        <script type='text/javascript' src=''></script>

        After re-enabling UGL, it looks like:

        <script type='text/javascript' src=''></script>
        <script type='text/javascript' src=''></script>
        <script type='text/javascript' src=''></script>

        … and the ui-tabs.js doesn’t appear anywhere else in the code :(

        Any ideas?

          1. OK, I take it that applies to ui-sortable and ui-resizable too?

            I just installed WordPress 2.9.2 in a fresh VM, added the CONCATENATE_SCRIPTS = false define and installed WP System Health and UGL again just to see if it was my install that caused the problem & it still doesn’t work, the differences from UGL being Off ( – ) to On ( + ) are:

            - var userSettings = {'url':'/','uid':'1','time':'1270270109'};
            + var userSettings = {'url':'/','uid':'1','time':'1270270174'};



            With UGL off, clicking on any of the “details” buttons on the System Health dashboard widget displays the system information correctly.

            With UGL on, clicking them just makes the “details” button vanish.

            Could the re-ordering function that WordPress System Health has be causing the issue?

          2. Sorry, your <code> ate my code :)

            - <script type='text/javascript' src=''></script>
            + <script type='text/javascript' src=''></script>

            + <script type='text/javascript'>try{jQuery.noConflict();}catch(e){};></script>

            - <script type='text/javascript' src=''></script>
            - <script type='text/javascript' src=''></script>
            + <script type='text/javascript' src=''></script>

            - <script type='text/javascript' src=''></script>
            - <script type='text/javascript' src=''></script>

  60. Heya, installed your script, or tried to, and got the following error

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/25/d184093902/htdocs/matthewhare/wordpress/wp-content/plugins/use-google-libraries/use-google-libraries.php on line 43

    I’m presuming it’s because my server is running PHP4.something. I can’t find out from them. It’s annoying because I’ve love this to work! :)

  61. Hey Jason,

    I think I may have found another compatibility issue. I have your plugin installed, but the jQuery code I’m using isn’t working unless I explicitly include the google jQuery library myself directly above my JS, which leads me to believe that there is something that is disabling or overriding the jQuery include in the header.

    I’d be more than happy to help you track down the issue.



    1. Sorry Jason, scratch that. I didn’t realize “$” is a reserved symbol in WordPress. I changed the “$” in my code to “jQuery” and the code work just fine.

      Again, I apologize for any confusion.

      Thanks for a great plugin.

  62. Hey Jason!

    Great plugin man.

    But guess what?

    WP 3.0 is out and it’s time for that Use Google Libraries upgrade.

    Through painful troubleshooting I discovered Google Libraries was responsible for disabling insert image lightbox pop-up, edit and resize image in wyswig and html/wyswig toggle tabs.

    Let me know if and when you upgrade and I will reinstall on my sites.


    1. Thanks for the kind words. The plugin has been updated twice since 3.0 came out. What version are you using? If you have the latest ( please give me some more details as to exactly what you’re seeing and I’ll look into it.

  63. Jason

    Awesome post! Saved me a lot of time!

    I think you maybe able to help me solve an issue.

    I have multiple sites on a dedicated server that run WordPress. After an Apache upgrade, the Ajax portion of WordPress no longer works.

    When I install the plugin you recommend, it works.

    Any suggestions?

  64. I apologize for the basic question, but could you please clarify:
    1) Does this script automatically load all the libraries listed (Dojo, jQuery, jQuery UI, MooTools, Prototype,, swfobject)?
    2) If so, can we limit it to just 1 or 2 libraries? (I’m only using jQuery)
    3) If not, how do we specify which libraries to load?

      1. Thanks Jason. So, after uploading and activating use-google-libraries, would good practice be:
        a) edit the function.php file (not header.php);
        b) insert the code:

        function my_init_method() {
            if (!is_admin()) {
                wp_enqueue_script( 'jquery' );
        add_action('init', 'my_init_method');
        1. Technically, yes, although that won’t do much unless you’ve got a script file that depends on/makes use of jQuery, and in that case you should just do:


          This tells WordPress ‘my_script’ (located in the ‘js’ folder under your theme) relies on jQuery, and the script loader will handle the rest.

          1. Thanks, Jason, I was wondering the best way to do load a jQuery plugin as well.

  65. please, do not add javascript code across all admin pages! I’m having conflict with javascript in some cases.

    Currently it’s with the NGGallery plugin’s album page…I couldn’t drag galleries and albums, and when i disabled your google libraries, it worked again…

    1. This plugin does not add any javascript code to the admin pages. It only changes where scripts are enqueued from.

      I coludn’t find a NGGallery. Do you mean NextGEN Gallery, or is it some other plugin?

      Update: I just tried a WordPress install with only NextGEN Gallery and Use Google Libraries and drag-and-drop worked fine in the gallery admin, so it may be another plugin causing the issue.

    2. Would using the code above in 29 solve the problem? Embedding the call in the following code prevents it from running in admin pages.
      if (!is_admin()) {

      1. Jean,

        There is no call for aki to embed. aki is enabling a plugin, that is attempting to enqueue a script supported by Use Google Libraries, and something isn’t working.

        Unfortunately I can’t reproduce it with just these two plugins enabled, so I have no idea what’s happening.

  66. What has changed from version to version 1.1.2? The changelog isn’t updated yet.

    Thanks, Steve

    1. Looks like something is funky with WordPress’s plugin trac at the moment. The only really visible change is that it works better with WordPress 3.1 Release Candidates.

  67. Hi, how do I get my libraries to use the latest version on Google? I looked through the code and can’t find anywhere, for instance where I can change from using jQuery 1.4.2 to 1.5.0 =(


  68. Hello, I’m experiencing a conflict with Use Google Libraries and the accoridon widget. Without it active it calls naturally and it works, but with it on it seems to break and firebug throws this error: “m is undefined” … I’m not certain but I think it’s because the UI does not naturally support accordion? Please advise? I can modify the code of the plugin.

    1. I figure out it was because the plugin called this file, which conflicted with Use Google Librarie’s UI call :

      Is there any way I can detect if a UI has already been called, and if there isn’t a UI called then call the above code? I appreciate your help!

      1. My guns are quick! Here’s a solution.

        if ($.ui == “undefined”)
        js_script = document.createElement(\’script\’);
        js_script.type = “text/javascript”;
        js_script.src = “”;

        Thanks for the great plugin!

      2. Can you tell me what plugin you’re using for the accordian? It just needs to correctly call the WordPress API wp_enqueue_script('jquery-ui-accordion'); and everything should work. Do you have a link to the plugin in question?

        1. It’s a commercial plugin called WP Traffic Tools (Link in name above) that I’m working on, and noticed the conflict recently on one of my blogs running your plugin. , Are you saying that WordPress naturally provides jquery; is there any version control in it? For example there are some improvements in the 1.8.9 ui that affects accordion behavior. It seems that Use Google Libraries version (1.7.x) does the job just fine too.

          For the mean time he code mentioned above solved the conflict, but if I can do it better I’d be willing to change the way I call jquery into the plugin.

          1. Yes, WordPress has a definitive way in which scripts and stylesheets are supposed to be loaded by plugins and themes.

            In your case, all you need to do is something like this in your php:

            function my_plugin_init_method() {
            /* ... */
            add_action('init', 'my_plugin_init_method');

            This ensures that you use the jQuery stack that’s compatible with the WordPress install, and that you don’t conflict with other plugins. It also ensures that script dependencies are enforced (jquery loads before jquery-ui, etc).

  69. Hello.

    Wonderful plugin! It actually make jQuery (UI) works (if I enqueue WP’s jquery-ui without yout plugin, it just doesn’t work).

    May I suggest to add also support to jQuery UI themes? They also are in Google CDN.

  70. This morning I had an issue with WP menus. Like most people, I’m fed up with conflicts with plug-ins and everything stopping suddenly after I’v spent days building a site. In fact, I’m going to invest in WooThemes for mass poduction sites because they just work! I’ll also invest in their recommended plug-ins for forms and seo.

    Thank you for your awesome “Use Google Libraries” plug-in and I would like to thank your blog for basically saving my bacon!

  71. Hello Jason, first of all I want to thank you for such a nice plugin. I have been using it for a long while. Looks like plugin is not compatible with WordPress 4.0. When I had it activated media library functions wasn’t working for my site. I had to deactivate it to get everything running. I just wanted to remind you about the issue.

    1. I couldn’t reproduce the issue, but I’ve released a new version with some long pending updates. Let me know if that helps (or not).

  72. using with wp-super-cache.
    it works if login as admin (which wp-super-cache did not cache)
    but not working as anon reader (which wp-super-cache create a cache)

    btw. it’ll be great to combine with cdnjs, bootstrapcdn and jsdelivr

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.