Àpèjúwe
A number of the javascript libraries distributed with WordPress are also
hosted on GoogleÌtumọ̀ Yorùbá: ’s AJAX Libraries API.
This plugin allows your WordPress site to use the content distribution
network side of GoogleÌtumọ̀ Yorùbá: ’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Ìtumọ̀ Yorùbá: ’s servers are set up to negotiate HTTP compression with the requesting browser
For a more detailed look see Dave WardÌtumọ̀ Yorùbá: ’s 3 reasons why you should let
Google host jQuery for
you.
Supported Libraries and Components
Links
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
this.
Gravity Forms
IÌtumọ̀ Yorùbá: ’ve had reports of Gravity Forms breaking UGL, but I donÌtumọ̀ Yorùbá: ’t have
access to Gravity Forms, so IÌtumọ̀ Yorùbá: ’m not sure whatÌtumọ̀ Yorùbá: ’s going on. If you need
Gravity Forms you might need to disable UGL, or it might be fine, IÌtumọ̀ Yorùbá: ’m
not really sure.
WP-Minify
WP-Minify doesnÌtumọ̀ Yorùbá: ’t yet support protocol-relative URLs. Add
‘//ajax.googleapis.com/’ as a JS and CSS exclusion.
Incompatible Themes
K2
IÌtumọ̀ Yorùbá: ’ve had scattered reports that UGL is stepping out of the way when
using K2.
A Request
If youÌtumọ̀ Yorùbá: ’re going to flag the plugin as “broken” in the WordPress Plugin
Directory, please try and let me know what is
broken.
IÌtumọ̀ Yorùbá: ’m not a mind reader.
Technical Details
Use Google Libraries uses the following hooks (each with a priority of 1000).
wp_default_scripts
Use Google Libraries compares itÌtumọ̀ Yorùbá: ’s list of supported scripts to those
registered, and replaces the standard registrations src with ones that
point to GoogleÌtumọ̀ Yorùbá: ’s servers. Other attributes (like dependencies) are left
intact.
script_loader_src
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
ajax.googleapis.com. Otherwise the URL is left unaltered. This both
improves the chances of the given URL already being cached, and prevents
script.aculo.us 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Ìtumọ̀ Yorùbá: ’s noConflict mode as it would
with the standard WordPress version.
References
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Ìtumọ̀ Yorùbá: ’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
Ìgbéwọlẹ̀
Upload the use-google-libraries folder to the /wp-content/plugins/ folder.
Activate Use Google Libraries through the ‘Plugins’ menu in WordPress.
Er… ThatÌtumọ̀ Yorùbá: ’s it really.
FAQ
- Installation Instructions
- Upload the
use-google-librariesfolder to the/wp-content/plugins/folder.Activate Use Google Libraries through the ‘Plugins’ menu in WordPress.
Er… ThatÌtumọ̀ Yorùbá: ’s it really.
- What happens when Google updates their library versions?
-
Google has stated that they intend to keep every file theyÌtumọ̀ Yorùbá: ’ve hosted
available indefinitely, so you shouldnÌtumọ̀ Yorùbá: ’t need to worry about them
disappearing. - Why isnÌtumọ̀ Yorùbá: ’t in doing anything?
-
Firstly, if you are using a caching plugin, flush the cache or
temporarily disable it to be sure itÌtumọ̀ Yorùbá: ’s not doing anything. That said,
IÌtumọ̀ Yorùbá: ’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Ìtumọ̀ Yorùbá: ’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
Libraries. IÌtumọ̀ Yorùbá: ’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. - How do I use the libraries supplied by Use Google Libraries?
-
The same way you use them when Use Google Libraries isnÌtumọ̀ Yorùbá: ’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. - Why do some scripts continue to use the WordPress supplied versions?
-
Assuming some other plugin or theme isnÌtumọ̀ Yorùbá: ’t the cause, Use Google Libries does
itÌtumọ̀ Yorùbá: ’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Ìtumọ̀ Yorùbá: ’t hosting, then it will continue to use the WordPress supplied
version. - Can I always load the latest version of a hosted script?
-
No. Use Google Libraries doesnÌtumọ̀ Yorùbá: ’t do that because it would almost certainly
break WordPress. Even if it didnÌtumọ̀ Yorùbá: ’t, the less ‘version specific’ URLs supported
by GoogleÌtumọ̀ Yorùbá: ’s CDN set a short term ‘Expires’ header, so there wouldnÌtumọ̀ Yorùbá: ’t be much
point.
Àwọn àgbéyẹ̀wò
Àwọn Olùkópa & Olùgbéejáde
“Use Google Libraries” jẹ́ ètò ìṣàmúlò orísun ṣíṣí sílẹ̀. Àwọn ènìyàn wọ̀nyí ti ṣe ìkópa sí plugin yìí.
Àwọn OlùkópaA ti túmọ̀ “Use Google Libraries” sí àwọn èdè agbègbè 6. Ọpẹ́lọpẹ́ fún àwọn atúmọ̀ èdè fún àwọn ìkópa wọn.
Túmọ̀ “Use Google Libraries” sí èdè rẹ.
Ṣe o nífẹ̀ẹ́ sí ìdàgbàsókè?
Ṣàwárí koodu, ṣàyẹ̀wò ibi ìpamọ́ SVN, tàbí ṣe àgbékalẹ̀ sí àkọsílẹ̀ ìdàgbàsókè nípasẹ̀ RSS.
Àkọsílẹ̀ àwọn àyípadà
1.6.2.3
- Updated supported version.
- used archive.org to get around link thatÌtumọ̀ Yorùbá: ’s now malware
1.6.2.1
- Bypass functionality when running under 4.2+ until next version to avoid breaking sites.
1.6.2
- added some missing jQuery UI modules (hopefully fixes issues from support
forums I couldnÌtumọ̀ Yorùbá: ’t reproduce previously).
1.6.1
- same as 1.6 (due to SVN issue with 1.6)
1.6
- Drop support for PHP4, and WordPress < 3.4
- clean up PHP 5.x strict issues
1.5.2
- using protocol-relative URLS with WordPress >= 3.5
- use WordPress provided
is_sslrather 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).
1.5.1
- fix bug in
is_sslcheck.
1.5
- using
wp_remote_headto query that the replacement URL is actually
hosted by google. If itÌtumọ̀ Yorùbá: ’s not, then the WordPress supplied version will be
used. - Using the Transient API to store the replacement URLS, rather than
recalculating and re-querying them every load.
1.2.1
- Added check for WordPress including non-standard versions of scripts (fixes
WordPress 3.2.2/swfobject). - Fixed incorrect case in HTTPS check.
1.2
- Reworked handling for cases where multiple js files are combined
into one on GoogleÌtumọ̀ Yorùbá: ’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.
1.1.2
- Updated jQuery UI to work with WordPress 3.1rc1
1.1.0.1
- Re-disable script concatenation. Seemed to break widget admin page.
1.1
- No longer disable script concatenation when using WordPress 3.0 or
greater - 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.
1.0.9.2
- Hopefully fix issue with plugin loading for some users
1.0.9.1
- Added Incompatible Plugins and Incompatible Themes sections
to the README
1.0.9
- more https detection
- inline jQuery.noConflict()
1.0.7.1
- fix previous fix (whoops!)
1.0.7
- Quick and dirty workaround for scriptaculous loading (thanks to
Gregory Lam for bringing it to my
attention
1.0.6.1
- moved location of the Changelog section in the README
1.0.6
- 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
1.0.5
Implemented a pair of
suggestions
from Peter Wilson.
- 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Ìtumọ̀ Yorùbá: ’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Ìtumọ̀ Yorùbá: ’s
servers. If the version requested by your WordPress install
changes, so will the URL so thereÌtumọ̀ Yorùbá: ’s no worry that youÌtumọ̀ Yorùbá: ’ll keep
loading an old version.