Detect 'interactive' ready state

The readyState value should be 'loading', 'interactive', or 'complete'
while 'loaded' appears in old WebKit browsers.

The document 'DOMContentLoaded' event is associated with 'interactive'
and may be fired before sub-resources (e.g. images) are fully loaded.

This change also skips adding an event listener if the DOM is ready by
the time the domready script is executed.