Skip to content

Instantly share code, notes, and snippets.

@getify
Created June 27, 2011 13:45
Show Gist options
  • Save getify/1048881 to your computer and use it in GitHub Desktop.
Save getify/1048881 to your computer and use it in GitHub Desktop.
how to not miss window.onload in dynamic script loading case
<html>
<head>
<script src="LAB.js"></script>
...
<script>
function do_something() { /* ... */ }
(function(){
var _winload = false;
window.onload = function(){ _winload = true; };
$LAB
.script(...)
.script(...)
.wait(function(){
if (_winload) do_something();
else window.onload = do_something;
});
})();
</script>
...
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment