• JavaScript
domReady v3 – JavaScript (Cross Browser)


With domReady v3 allows you to execute when the code DOM ready is. It works in all modern browser and even from IE version 6.

Onload versus DOMContentLoaded

There is a window onload event, but it only works if all loaded on the page is. The DOMContentLoaded event become a lot more done, only works not for all browsers.

Without Framework

Most frameworks like jQuery and Mootools therefore have a separate DOM ready function built. But what if you do not use such a framework? Then you can standalone Using version.

How does the domReady?

With domReady you add features that should be executed when the DOM is loaded.

domReady(function () {
    alert('DOM is ready!');

// is equal to
domReady.on(function () {
    alert('DOM is ready!');

Or give argumenten along to the callback function:

was param1 = 'hello';
can param2 = 1234;

domReady.params([param1, param2]);

// params will be passed on to the handler
domReady.on(function (arg1, arg2) {
    // arg1 = 'hello' and arg2 = 1234

Error callback

domReady.error(function (err) {

Functies (API)

  • d‍omR‍eady( fn ) *
  • d‍omR‍eady.on( fn )
  • domReady.params( params )
  • d‍omR‍eady.error( fn )

*) Were equivalent domReady.on()

Browser Support

Tested in IE6 , FF, Opera, Chrome and Safari (for Windows).


Je they latest version of the domReady Download on Github.

Related Articles

No comments yet.

Send your comment


Fork me on GitHub