Reference position of link tag and script tag

  • The link tag is placed in the head tag

    • When the user visits the website, the code is parsed from top to bottom to normally display the style of the page content, improving user experience
    • When placed at the bottom of the html structure, the html structure will be confused when loading the page
  • The script tag is placed before the closing body tag

    • js script blocks html parsing during download and execution
    • Put the script tag at the bottom to ensure that the html and css are parsed first and then the js script is loaded
    • When the script tag is added with the defer attribute, it can be placed in the head tag
<script defer></script>

Guess you like

Origin blog.csdn.net/Dajdhushvj/article/details/126834837