@@ -61,7 +61,7 @@ WebLink:
6161
6262 <head>
6363 <!-- ... -->
64- <link rel="stylesheet" href="{{ preload('/app.css') }}">
64+ <link rel="stylesheet" href="{{ preload('/app.css', { as: 'style' } ) }}">
6565 </head>
6666
6767If you reload the page, the perceived performance will improve because the
@@ -75,7 +75,7 @@ the priority of the resource to download using the ``importance`` attribute:
7575
7676 <head>
7777 <!-- ... -->
78- <link rel="stylesheet" href="{{ preload('/app.css', { importance: 'low' }) }}">
78+ <link rel="stylesheet" href="{{ preload('/app.css', { as: 'style', importance: 'low' }) }}">
7979 </head>
8080
8181.. tip ::
@@ -88,8 +88,7 @@ How does it work?
8888
8989The WebLink component manages the ``Link `` HTTP headers added to the response.
9090When using the ``preload() `` function in the previous example, the following
91- header was added to the response: ``Link </app.css>; rel="preload" ``
92-
91+ header was added to the response: ``Link </app.css>; rel="preload"; as="style" ``
9392According to `the Preload specification `_, when an HTTP/2 server detects that
9493the original (HTTP 1.x) response contains this HTTP header, it will
9594automatically trigger a push for the related file in the same HTTP/2 connection.
@@ -105,7 +104,7 @@ issuing an early separate HTTP request, use the ``nopush`` option:
105104
106105 <head>
107106 <!-- ... -->
108- <link rel="stylesheet" href="{{ preload('/app.css', { nopush: true }) }}">
107+ <link rel="stylesheet" href="{{ preload('/app.css', { as: 'style', nopush: true }) }}">
109108 </head>
110109
111110Resource Hints
@@ -139,7 +138,7 @@ any link implementing the `PSR-13`_ standard. For instance, any
139138 <head>
140139 <!-- ... -->
141140 <link rel="alternate" href="{{ link('/index.jsonld', 'alternate') }}">
142- <link rel="stylesheet" href="{{ preload('/app.css', { nopush: true }) }}">
141+ <link rel="stylesheet" href="{{ preload('/app.css', { as: 'style', nopush: true }) }}">
143142 </head>
144143
145144The previous snippet will result in this HTTP header being sent to the client:
@@ -160,7 +159,7 @@ You can also add links to the HTTP response directly from controllers and servic
160159 public function index(Request $request)
161160 {
162161 $linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
163- $request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css')));
162+ $request->attributes->set('_links', $linkProvider->withLink(new Link('preload', '/app.css', ['as' : 'style'] )));
164163
165164 return $this->render('...');
166165 }
0 commit comments