cheatsheet1999/FrontEndCollection

A brief introduction of the differences between "src" and "href"

cheatsheet1999 opened this issue · 0 comments

  • src is used to replace current element, href is used to build connection between two files.

    <script src="script.js"></script>

    When the browser parses this line of code, it will pause any other execution until the browser finishes executing this line and downloading the source.

    That is the reason why we should put Javascript on the end of the file, instead of on the top.

  • href is the abbr of Hypertext Reference, it connected to the target source file

    <link href="style.css" rel="stylesheet"/>

    The browser will recognize the file is a css file, and then download the resource but NOT stop to execute current file

    That is why we should use link to load css, instead of @import