Using Google-hosted jQuery library

Written by stevey on August 9th, 2010

Nice thing about using Google hosted jQuery is that I could call jQuery lib from anywhere and take advantage of versioning  and compression maintenance work done by Google. According to some source, the better caching provided by Google actually speed up the loading of the javascripts.

For example, below is a dialog box that uses jQuery UI hosted at Google. Click on the link to see it in action.

Show Dialog

Source code:

<link href=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css” rel=”stylesheet” type=”text/css” />
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js”></script>
<script src=”http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js”></script>
<script type=”text/javascript”>
function showDialog() {

$(“#dialog”).dialog({autoOpen:false, modal:true,buttons: {OK:function(){$(this).dialog(‘close’); }}});

$(“#dialog”).dialog(‘open’);

}

</script>

<div id=”dialog” title=”hello dialog”></div>

 

Leave a Comment