you-dont-need-x / you-dont-need-jquery

The next evolutive state of, "You Might Not Need jQuery", because you definitely don't need jQuery.
The Unlicense
121 stars 10 forks source link

replacement of document.ready #6

Open wizardforcel opened 8 years ago

wizardforcel commented 8 years ago

DOMContentLoaded has been added in HTML5. So:

jQuery:

$(() => {
    //...
});

Modern:

// HTML5
document.addeventListener('DOMContentLoaded', () => {
    //...
});

// HTML4
document.onreadystatechange = function() {
    if(document.readyState == 'complete') {
        //...
    }
};
maniator commented 8 years ago

:+1:

ndugger commented 8 years ago

I will definitely get around to adding this in soon. Thanks.

wizardforcel commented 8 years ago

In fact, there is also a replacement in HTML 4. I've updated it.