Skip to main content
100%

basic DOM Ready

✓ Published0🌍 Public
Aalessioalex
Last edited Nov 18, 2011
Created on Nov 18, 2011

This example demonstrates a lightweight DOM-ready utility that detects when the document is fully loaded and executes registered callback functions. It handles browser-specific quirks by using `document.addEventListener` for Mozilla and Opera, a `doScroll` check for Internet Explorer, and a stylesheet-counting fallback for Safari. The code exposes a `DomReady.ready` method to queue functions, running them immediately if the DOM is already ready or deferring them otherwise. A final fallback ensures `window.onload` triggers the pending callbacks.

AI-generated description

Similar vizzes