jpenney / use-google-libraries

WordPress plugin: Allows your site to use common javascript libraries from Google's AJAX Libraries CDN, rather than from WordPress's own copies.
10 stars 4 forks source link

jQuery fallback #10

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi,

Thanks for a good plugin. I've just realized there's a problem with it, though. I've recently added the ability to see the kind of errors my visitors get in their JS console to my website, and I've realized that problems with loading jQuery are the most frequent! This is not a problem I'm the only one to have. Luckily, there's a pretty easy solution to this:

// First try loading jQuery from Google's CDN
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

// Fall back to a local copy of jQuery if the CDN fails
<script>
window.jQuery || document.write('<script src="http://mysite.com/jquery.min.js"><\/script>'))
</script>

Could you please add something like this directly in the plugin?

Thanks and best regards, Maxime.

jpenney commented 9 years ago

I'd love to do this, unfortunately it relies on an enhancement to WordPress itself (#14853). If/when that's implemented I'll add this.

retlehs commented 9 years ago

not necessarily dependent on an update to core. we've had a local jquery fallback in our starter theme for years based on http://wordpress.stackexchange.com/a/12450