Letting Google host jQuery for you

Include this:

<script src=”//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js” ></script>

and implement like this:

<script>

  $(document).ready(function() {

     alert(“let’s go…”);

  });

</script>

For example:

$( “.replace_with_element_classname_clicked” ).on( “click”, function( event ) {

 $(“.replace_with_element_classname_to_show”).toggle([1000]);

});

Why?

  • You’re using the Google APIs CDN which means decreased latency 
  • Increased parallelism (your browser typically limits you to 2 connections per hostname)
  • Better caching (many users will already have cached this library) 

Wonder why the src is missing http:?

This is a handy trick to use a single reference for both http and https pages.

Leave a Reply

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