Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is LINK rel=subresource used for?

What is link rel="subresource" used for? What difference would that make if I use link rel="subresource" instead of link rel="text/javascript" for including .JS files?

like image 358
user3456791 Avatar asked Apr 06 '15 17:04

user3456791


2 Answers

Chrome is going to remove <link rel=subresource> because it is not useful, proprietary, and buggy.

See https://crbug.com/581840
Removed in Chrome 50 https://www.chromestatus.com/feature/6596598008119296

Use <link rel=preload> instead.
https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content

like image 74
j.j. Avatar answered Oct 22 '22 11:10

j.j.


As of 2016 the subresource value for the rel attribute was deprecated and removed.

It has been superseded by the Preload API instead, meaning one should do rel=preload for a similar effect. To quote the specs

The preload keyword on link elements provides a declarative fetch primitive that initiates an early fetch and separates fetching from resource execution.

As such, the preload keyword serves as a low-level primitive that enables applications to build custom resource loading and execution behaviors without hiding resources from the user agent and incurring delayed resource fetching penalties.

For example, the application can use the preload keyword to initiate early, high-priority, and non-render-blocking fetch of a CSS resource that can then be applied by the application at appropriate time.


Below is the original answer written in 2015, for posterity, that explains the then valid subresource keyword.


The rel=subresource link is what is called Link prefetching, where the browser tries to fetch the resource before it's needed, so it can load that resource faster from cache when it is in fact needed later on.

Link prefetching is a browser mechanism to download or prefetch resources.

Link prefetching is a browser mechanism, which utilizes browser idle time to download or prefetch documents that the user might visit in the near future. A web page provides a set of prefetching hints to the browser, and after the browser is finished loading the page, it begins silently prefetching specified documents and stores them in its cache. When the user visits one of the prefetched documents, it can be served up quickly out of the browser's cache.

The server provides hints to the browser and the browser can consult its cache and take action based on these hints.

The existing link prefetching uses a standard HTTP link header, and defines semantics for the link relation type "prefetch".

link rel=subresource provides a new link relation type with different semantics from link rel=prefetch.

While rel=prefetch provides a low-priority download of resources to be used on subsequent pages, rel=subresource enables early loading of resources within the current page. Because the resource is intended for use within the current page, it must be loaded at high priority in order to be useful.

like image 24
adeneo Avatar answered Oct 22 '22 13:10

adeneo