i wonder if i use
google.load("jquery", 1);
google.setOnLoadCallback(function() {
// i still need to check if document has finished loading with
$(function() {
// do stuff
});
});
the question is when google.setOnLoadCallback() is called it does not mean the document has finished loading right? or can i do stuff like ... below ... straight away?
google.setOnLoadCallback(function() {
$("#elem").doSomething();
});
From Google AJAX API docs:
window.load
will always fire afterDOMContentLoaded
that is the equivalent ofjQuery(document).ready
for most cases. When not available, jQuery will fallback toonreadystatechange
oronload
(IE), orload
(standard).Since worst case if both jQuery and google falling back to the
load
event, you can safely use the second method.