WordPress Code Snippets

A fresh mix of code snippets and tutorials

Include external, current version of jQuery

96

Quick tip for including (linking to) the current version of jQuery from external sources.

Include current jQuery from Google API

To always include the latest Google-hosted version of jQuery (minified), add this to the head or footer of your web page(s):

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Notice that the http: portion of the protocol is not included. This enables the script to seamless load jQuery according to the specific protocol, HTTP or HTTPS. If you’re not using one or the other, you can replace // in the URL to either http:// or https://.

Also, here’s how to link to a specific version of jQuery:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

Include current jQuery from jQuery.com

jQuery.com also hosts the latest version of jQuery (minified). To include it in your web page(s), add the following code:

<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

..and here it is again using an alternate shorter URL:

<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>

Related


Show Support

Like our new Facebook Page to show support!