Check if document.readyState === 'complete' before trying onload listeners

Add check if the document is already ready, and if so skip the onload handlers. Fixes live loading of markdown forms

Otherwise, continue as normal.

I do a lot of server side form rendering (mainly for CSRF tokens) and loading the forms into the page (lightbox, etc) through jquery.load, and this fixes pagedown in those use cases. Does not cause problems otherwise