Statement: All of my blogs are personal notes, used as personal knowledge index, so there are logic problems in the narrative, the span is large, I hope to understand. Share out for everyone to learn to read, if there is a mistake hope to point out, thank you!
< script> Tag properties:
Async: Optional, indicating that the script should be downloaded immediately but should not interfere with other operations on the page
Defer: Optional, which means that the script can be deferred until the document is fully parsed and displayed, and is valid only for external scripts
SRC: Optional, representing the external file that contains the code to execute
Type: Required, representing the content type of the scripting language in which the code is written, typically text/javascript
Use external JavaScript files
In the use of & lt; script> When embedding external JavaScript code, do not appear anywhere in the code. /script>
If you want to pass < script> Element to contain an external JavaScript file, then SRC is required. SRC points to a link to an external JavaScript file, either relative or absolute
The processing of the page also stops temporarily when downloading and parsing external JavaScript files
& LT with SRC attribute; script> JavaScript code should no longer be included between tags, and even if it was, it would be ignored
External JavaScript files carry a.js extension that can be ignored, but the server must return the correct MIME type
Label location
Placed in & lt; body> At the end of the
Because: The browser processes the HTML code sequentially, if placed at the beginning will cause the browser to first download and process the JavaScript external files, thus causing the web page to be placed in the < head> And add defer= “defer”
<script type="text/javascript" defer="defer" src="xxx.js"></script>
The because: Defer property causes the script to be deferred until the entire page has been loaded, called the defer script, which is best left with only one placed at < head> In, and add Async
<script type="text/javascript" async src="xxx.js"></script>
The because: Async attribute instructs the browser to download the script file immediately, but it should not prevent other actions on the page marked async from ensuring that the script is executed in the order in which it is recommended to place the script at < body> The end of the method
Read More:
- How to use dangerously set inner HTML in react
- How to center the box horizontally and vertically in HTML
- How to restrict input field to only input pure numbers in HTML
- Use XMLHttpRequest of JavaScript to send data to the background
- How to Use spatial in MAC
- How to use higher version of OpenGL SDK in windows?
- How to Use Subfigure in Latex
- How to center your HTML button itself? ——Use the align attribute of center or Div
- The @ Autowired annotation in springboot is invalid in ordinary classes. How to solve and use the null pointer exception java.lang.nullpointerexception
- Vscode HTML file auto supplement HTML skeleton failure
- [Vue warn]: Do not use built-in or reserved HTML elements as component id: article
- How to use scanner to accept char type characters in Java
- How to solve oserror: [errno 98] address already in use and kill the python3 process
- How to use it RegAsm.exe Register C in a development / production environment#/ VB.NET Developed DLL
- A JavaScript error occured in the main process
- To solve the problem of failed to load: data in HTML5 game running rmmv locally/ actors.json problem
- There will be row spacing problems in algorithm use in latex. Please use the ‘setstretch {1.35}
- How to Use Truffle to Deploy contracts on moonbeam
- C#: How to Use Httpclient to upload files with other parameters
- A JavaScript error occurred in the main process