[Interview] Interviewer: The difference between src and href

 1. Different request resource types
(1) href is the abbreviation of Hypertext Reference, which means hypertext reference. Used to establish a link between the current element and the document. The commonly used ones are: link, a.
(2) When the src resource is requested, the resource it points to will be downloaded and applied to the document. The commonly used ones are script, img and iframe; 2. Different
results
(1) href is used to establish a link between the document and the resource
; 2) src is used to replace the current content;
3. Browser parsing methods are different
(1) With href, the browser will recognize the document as a CSS file, download resources in parallel and will not stop processing the current document.
(2) Using src will suspend the download and processing of other resources until the resource is loaded, compiled, and executed, and the pointed resource will be applied to the current content. This is why it is recommended to put the js script at the bottom instead of the head.

Guess you like

Origin blog.csdn.net/qq_46580087/article/details/124757622