Handle cases where onload handler is attached after onload

It's possible that a plugin attaches an onload handler after onload.  In
this case, fire the handler as soon as possible, and trust it to use
navtiming (where available) to determine when onload actually fired.
implement a setImmediate function, and use it
if document.readyState is already complete, then fire page_ready immediately