- Courses
- HTML
- HTML top level tags
- <link>
- Purpose of the as attribute in link
What is the purpose of the as
attribute in the <link>
element?
The as
attribute specifies the type of content being preloaded.
In the <link>
element, the as
attribute is used to define the type of content being preloaded, such as font
, image
, or script
. This attribute is crucial for request prioritization and ensuring that the correct content security policy is applied. It helps the browser handle the preloaded resource appropriately, optimizing loading performance.
<link rel="preload" href="font.woff2" as="font" type="font/woff2" crossorigin="anonymous" />