I'm sorry, if my question is very simple, but can't understand it. As I understand it's good practice to attach links/buttons listeners via js but not html. I mean this is bad practice:
<a href="javascript:" onclick="temp();">
And this is good
<a href="javascript:" id="mylink">
in js code
$("#mylink").on...
As I understand the main idea is that html page mustn't contain any javascript code, and all js code must be in js file. Ok, I like this idea.
The problem I see, implementing such approach is when to attach such listeners.
All I found - is that listeners can be attach only when document is ready (otherwise we can't add listeners to elements that are not ready).
However, if I have a page that shows for example 100 rows from database, then its loading is not fast (at comparison to short pages).
And if we wait until document is ready, the user can't work with site.
Please correct me if I'm wrong or say how can we make it to work with long pages without such things as timeouts.