If I got your question, actually I did make doOnDocumentLoaded the event listener.
Basically I need to do the same things twice, on line 2 in case document is still loading, and line 4 if the document is already loaded: this is why I declared the function first and use it as event handler in line 2 and call it in line 4.
Please reply if I'm wrong or I didn't fully understand your question.
Your event handler isn't doOnDocumentLoaded, rather it is an anonymous function that calls doOnDocumentLoaded - a rather unnecessary step when you could just usedoOnDocumentLoaded directly as the handler as I showed in my example
If I got your question, actually I did make doOnDocumentLoaded the event listener.
Basically I need to do the same things twice, on line 2 in case document is still loading, and line 4 if the document is already loaded: this is why I declared the function first and use it as event handler in line 2 and call it in line 4.
Please reply if I'm wrong or I didn't fully understand your question.
Your event handler isn't
doOnDocumentLoaded
, rather it is an anonymous function that callsdoOnDocumentLoaded
- a rather unnecessary step when you could just usedoOnDocumentLoaded
directly as the handler as I showed in my exampleAnd yes, you're totally right!
Sorry, and thank you so much!
I've just updated the gist!