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:
- doesn't domcontentloadedfires after script loaded, if they're setasync?
- isn't jquery's $(document).ready()supposed happen afterdomcontentloaded, why script fails?
if i'm wrong, how supposed avoid bottleneck caused not loading scripts asynchronously?
thank you.
 
 
  
Comments
Post a Comment