Google loads jQuery and jQueryUI

I am trying to use Google to download jQuery for some pages and the jQuery user interface for others. On pages where I just need jQuery, I do the following:

<script src="http://www.google.com/jsapi"></script> <script type="text/javascript"> function OnLoad() { // my jQuery goodness } google.load("jquery", "1"); google.setOnLoadCallback(OnLoad); </script> 

And on pages where I need jQueryUI, I also add the following:

 <link rel="stylesheet" type="text/css" href="/Library/jQuery/UI/Smoothness/css/smoothness/jquery-ui-1.7.2.custom.css"> <script type="text/javascript"> function OnLoadUI(){ $('div.tabs').tabs(); $('input.date').datepicker(); } google.load("jqueryui", "1"); google.setOnLoadCallback(OnLoadUI); </script> 

Q: Am I doing something wrong? This works, but I want to know if I am writing code that does not make sense. Q: Does Google have various css themes for the user interface? Or am I right in thinking that I need to cater for the topic of smoothness myself? (This is not a special topic - it's just the default).

+7
jquery
source share
1 answer

Looks nice. I'm just going to assume that Google is doing everything right, so the jQuery user interface can never load before jQuery, which is what the Developer's Guide suggests.

Google does not support themes, no. You will need to get them from the jQuery UI website and host them yourself.

EDIT: I take it back. See this blog post for links to Google’s CDN for popular topics. I never knew that!

So, to answer your question: you are doing everything right - except for this secret, undocumented list of CSS files. Good - keep up the good work!

+10
source share

All Articles