I have a html-webhandler which is writing back content asynchronously. While this is happening I want to scroll the page to bottom all the time until the page has been completely loaded.
My first attempt revolved around DOM-events such as DOMNodeInsertedIntoDocument
. But I soon realized these events don't fire on the initial page load.
My next attempt was to set a timer to scroll to bottom at every 50 or so ms. This kind of worked but I'd like to find a prettier solution.
So my question: Are there any standardized ways of getting events while a document is being parsed and loaded? I'd like to be able to execute a piece of js every time a new element is being added to the document on initial load.