Created
June 18, 2017 15:04
-
-
Save kadavre/28400b4bebc2253a57fea7eb1ac4f77c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// with jQuery | |
$(document).ready(function(){ /* ... */ }); | |
// shorter jQuery version | |
$(function(){ /* ... */ }); | |
// without jQuery (doesn't work in older IEs) | |
document.addEventListener('DOMContentLoaded', function(){ | |
// your code goes here | |
}, false); | |
// and here's the trick (works everywhere): | |
r(function(){ | |
alert('DOM Ready!'); | |
}); | |
function r(f){/in/.test(document.readyState)?setTimeout('r('+f+')',9):f()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment