Closed onur-km closed 3 years ago
@onur-km You mean downloading those scripts async, right? Actually all Js script execution happens synchronously, so there is no need to implement the feature as you have given above.
If you need to download scripts asynchronously, use the <link rel=preload>
technique. Defer.js only makes sure to defer execution of the JS code after the page has completely loaded.
@onur-km
For the last example, you could place the jquery load code in a callback function (fourth parameter) of the Defer.js function that loads moment.js.
Defer.js('https://cdnjs.cloudflare.com/ajax/libs/Swiper/6.4.15/swiper-bundle.min.js');
Defer.js('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js', null, 0, function(){
Defer.js('https://cdnjs.cloudflare.com/ajax/libs/jquery/jquery.min.js');
});
thx it looks good
Dom more than one Scripts are sync
Waterfall [||||||||| Swiper ||||||||] [||||||||||||| Moment |||||||||||||]
Dom more than one Scripts are async
Waterfall [||||||||| Swiper ||||||||] [||||||||||||| Moment |||||||||||||]
Scripts more than one are async
Waterfall [||||||||| Swiper ||||||||]
[||||||||||||| Moment |||||||||||||]
How to more than one Scripts are sync?
Waterfall
[||||||||| Swiper ||||||||]
[||||||||||||| Moment |||||||||||||] ----------------------------[|||||||||||||||||| Jquery ||||||||||||||||||||]
Thnx