ipel
ipel

Reputation: 1346

how to use google jsapi for jquery and jqueryui

Today i figured out that other the "standard way" to include jquery and jqueryui:

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>

There is another way, with the google jsapi:

<script src="//www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.4.2");
google.load("jqueryui", "1.7.2");
$(function() { $( document ).tooltip(); });
</sciprt>

Is the jsapi method better?

Because i've tried the jsapi method but it seems that only works with jquery and doesn't work with jqueryui, in fact the tooltip is not shown. What's wrong? Should I include the jquery css too? or maybe I need a key?

Upvotes: 1

Views: 1439

Answers (1)

Captain John
Captain John

Reputation: 2001

The idea is enhance the loading of your page. So your webpage rendering is not blocked whilst it downloads jquery and jqueryui. You will need to load your css too, I think you will need to do this inline, so you'll still need the link tag to load the jqueryui css.

Must admit I've not really used the google load api, but it appears to be doing a similar thing to requirejs i.e. dynamically loading client side scripts. It would be useful if you wanted to load different languages programatically. Perhaps if you had a scenario where maybe you don't need to load jqueryui in some conditions.

https://developers.google.com/loader/

Check out the above for a little more info.

Upvotes: 3

Related Questions