Any way to control Javascript Async Load Order?

后端 未结 2 1307
名媛妹妹
名媛妹妹 2020-12-19 00:58

How do I set the load and execution order of two external async Javascript files?

Given the following...



        
2条回答
  •  生来不讨喜
    2020-12-19 01:43

    You want to use defer if you want to preserve the execution order. What defer does is it async downloads the script, but defers execution till html parsing is done.

    
    
    

    However, you may want to start creating custom bundles once the number of scripts go higher.

    You can see the difference here

提交回复
热议问题