Skip to content

Instantly share code, notes, and snippets.

Forked from dciccale/
Last active Aug 29, 2015
What would you like to do?

DOM Ready

Tiny Cross-browser DOM ready function in 111 bytes of JavaScript.

<!doctype html>
var DOMReady = function(a,b,c){b=document,c='addEventListener';b[c]?b[c]('DOMContentLoaded',a):window.attachEvent('onload',a)}
DOMReady(function () {
alert('The DOM is Ready!');
<p>Tiny Cross-browser DOM ready function in 111 bytes</p>
* @param {function} a The function to execute when the DOM is ready
function(a, b, c) {
b = document
c = 'addEventListener'
b[c] ? b[c]('DocumentContentLoaded', a) : window.attachEvent('onload', a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment