Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cheatsheet1999 opened this issue Sep 10, 2021 · 0 comments
Open

Comments

@cheatsheet1999
Copy link
Owner

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant