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

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

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -