ded/domready — pull request #26 by macu (2014-02-22 01:44:23+00:00)
Title: Check "interactive", skip stuff if already loaded

Inlined the flush behaviour, and added `if (!loaded)` to skip the event listener stuff entirely if the DOM is ready when the domready script executes. This minifies nicely.

I also added a test for `^i` in the regex. This matches "interactive"—which is the value of `readyState` when the event "DOMContentLoaded" occurs. Allows the script to skip the event listener stuff if the state is "interactive" since the event will fire immediately anyway (at least in Chrome; but I was worried that the event listener for "DOMContentLoaded" might never be invoked if it was added after the state is already "interactive"). This is when the DOM is ready, although other resources like fonts and images may still be loading. ([reference](https://developer.mozilla.org/en-US/docs/Web/API/document.readyState))

Feel free to reject this one if you preferred the separate flush function :)