Difference between `script` and `link as=“script”` tags

蓝咒 提交于 2019-12-06 15:32:09

If that link tag had rel="preload" (or rel="modulepreload") on the it, it would indicate a preload request, which would preload, but not run, the script. Whereas of course, script loads and runs the script. But without rel, that link is invalid and has no useful effect (at least in terms of the specification).

If you look up link in the spec, you'll see as listed as:

as — Potential destination for a preload request (for rel="preload" and rel="modulepreload")

Following the link to as attribute, it says:

The as attribute specifies the potential destination for a preload request for the resource given by the href attribute. It is an enumerated attribute. Each potential destination is a keyword for this attribute, mapping to a state of the same name. The attribute must be specified on link elements that have a rel attribute that contains the preload keyword. It may be specified on link elements that have a rel attribute that contains the modulepreload keyword; in such cases it must have a value which is a script-like destination. For other link elements, it must not be specified.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!