Javascript: Async and jQuery's document ready / DOMContentLoaded -


i've 5 scripts need load on specific page. they're big libraries datatables or tinymce. i've been doing reading , found out use async in order not block page loading.

some of pages include code like:

<script type="text/javascript"> $(document).ready(function() {     $("#title").on('input propertychange paste', function() {         $("#slug").val(getslug($(this).val()));     }); }); </script>  

this code needs library loaded in order work. otherwise i'll get error saying function not available. — happening right now.

my doubts are:

  1. doesn't domcontentloaded fires after script loaded, if they're set async?
  2. isn't jquery's $(document).ready() supposed happen after domcontentloaded, why script fails?

if i'm wrong, how supposed avoid bottleneck caused not loading scripts asynchronously?

thank you.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -