iceangel89
iceangel89

Reputation: 6273

Google AJAX API, jQuery & google.load() vs $(function() {})

when i use google.load() to load jquery, what do i use in place of

$(function() {
 ... 
});

is ...

google.setOnLoadCallback(function() {
 ...
});

the same thing? this may be too slow if i am loading alot with google.load()?

then will

google.load("jquery", "1.3.2", {callback: docLoaded()});

run AFTER the whole document is loaded?

Upvotes: 0

Views: 1420

Answers (2)

Jean-Philippe Martin
Jean-Philippe Martin

Reputation: 911

Take a look here : Google Ajax Apis Playground

The way they do it is like this :

google.load("jquery", "1");

function OnLoad(){
  // some Jquery instructions
}

google.setOnLoadCallback(OnLoad);

Upvotes: 1

peirix
peirix

Reputation: 37741

I think you should be safe using $(function) still, since it will wait for google to load jQuery, it is after all a part of the document. Or am I wrong here?

I always use local versions anyway..Just feels safer, you know (:

edit: Just tested it, and it worked, just using the regular $(function)

Upvotes: 0

Related Questions