load scripts asynchronously

前端 未结 19 1310
粉色の甜心
粉色の甜心 2020-11-22 12:01

I am using several plugins, custom widgets and some other libraries from JQuery. as a result I have several .js and .css files. I need to create a loader for my site because

19条回答
  •  半阙折子戏
    2020-11-22 12:35

    Thanks to HTML5, you can now declare the scripts that you want to load asynchronously by adding "async" in the tag:

    
    

    Note: The async attribute is only for external scripts (and should only be used if the src attribute is present).

    Note: There are several ways an external script can be executed:

    • If async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)
    • If async is not present and defer is present: The script is executed when the page has finished parsing
    • If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page

    See this: http://www.w3schools.com/tags/att_script_async.asp

提交回复
热议问题