0

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?

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

Comments

0

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)

2 Comments

err i did google.load("jquery", "1.3.2"); google.load("maps", "2"); $(function () { alert("Hello"); }); and nth happened ...
Just would like to add, that $(function() {}) is the equivalent of $.ready() and is triggers before $.load() ! api.jquery.com/ready The difference is that for ready the DOM is built, but images, css artifacts might still not be all loaded.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.