Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make document.ready not wait for specific DOM elements to finish loading

I found myself in a following situation. I need to somehow not include <div class="article-meta-social"></div> element and all its contents into my document.ready function. The reason is, it has links to apis from facebook, twitter, g+ etc... and Multiplied by several posts it results in a little delay before contents within document.ready function are fired off. Therefore, what can I change in order for this

$(document).ready(function(){

});

To not wait until .article-meta-social and its contents are ready?

like image 621
Ilja Avatar asked Jun 17 '26 06:06

Ilja


1 Answers

$(document).ready relies on the native DOMContentLoaded event, which does exactly what it says - fires when the entire DOM has been parsed. So to achieve what you want, insert the contents of .article-meta-social dynamically inside your ready handler. This way it won't hold up the main rendering of your page.

like image 81
Graham Avatar answered Jun 19 '26 20:06

Graham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!