javascriptjquerywordpressdocument-readyready

Two definitions of jQuery ready


I'm trying to debug a strange behaviour on a Wordpress site: the code inside the first occurence of ready seems not to happen. Because of several plugins installed, I see this in code:

<script type="text/javascript">
jQuery(document).ready(function(){   (function() {   ... })();});
</script>

Then later, nearly at the end of the page I see:

<script type="text/javascript">
jQuery(document).on('ready post-load', easy_fancybox_handler );
</script>

Does one definition or "ready" override the other or will both actions happen?


Solution

  • As documented,

    When multiple functions are added via successive calls to this method, they run when the DOM is ready in the order in which they are added.

    So setting a ready handler twice is fine.

    However: