When I learnt JavaScript a few years back, jQuery was still considered good standard practice, and it was recommended that the main application code be called from the $document.ready()
event handler, so as to ensure the DOM was safe to use.
Fast forward a few years since the last time I worked on JavaScript, and the consensus nowadays seems to be to avoid jQuery. Also, since scripts are usually loaded at the very end of the HTML document, it seems that $document.ready()
might not be needed any longer.
In question $(document).ready equivalent without jQuery I see several modern alternatives for this piece of code. However, it is still not clear to me whether including any one of these is considered standard practice or recommended, in general.
So my question is about current practice: should I always include such code as the entry point of a Vanilla JS application, or, on the contrary, is it considered now safe to start loading the JS app without any wrappers?