Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
@cheatsheet1999

Description

@cheatsheet1999
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions