Skip to content

Comment on Faster than jQuery(document).ready() - Wait Until Existsparent

Comments

I think he meant faster as in executed before, rather than in executed faster.

Still doesn't answer the question: how much earlier is it executed? I would like to know.

actually, the script doesn't make any sense because it would be executed as soon as the browser is idling, that is after it has rendered the dom completely, that is when the DOMContentLoaded event fires. The right way to run a script right after an element has been created is to place the script right after the element closing tag.

You still can use it for setting late binding event handlers though.

It's using DOMNodeInserted (when available), which does fire as each element is created.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.