Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning: <link rel=preload> must have a valid `as` value

When trying to rel="preload" a video file using a <link> tag in the <head> I get a warning in the Chrome console stating:

<link rel=preload> must have a valid `as` value

My tag is:

<link rel="preload" href="https://storage.googleapis.com/[myFilePath].mp4" as="video" type="video/mp4" media="(min-width: 768px)" crossorigin>

like image 880
Tyler Hall Avatar asked Aug 08 '19 18:08

Tyler Hall


People also ask

What is preload in link rel?

The preload value of the <link> element's rel attribute lets you declare fetch requests in the HTML's <head> , specifying resources that your page will need very soon, which you want to start loading early in the page lifecycle, before browsers' main rendering machinery kicks in.

What is prefetch and preload?

Preload is an early fetch instruction to the browser to request a resource needed for a page (key scripts, Web Fonts, hero images). Prefetch serves a slightly different use case — a future navigation by the user (e.g between views or pages) where fetched resources and requests need to persist across navigations.


1 Answers

Maybe this warning is a bug

[as]- this attribute is used when rel="preload" or rel="prefetch" has been set on the element. It specifies the type of content being loaded/prefetched Instead, 'preload' you can also use 'prefetch'

<link rel="prefetch" href="./img/intro.mp4" as="video">

So You can accomplish your task

like image 89
Dpk Avatar answered Oct 03 '22 00:10

Dpk