@@ -27,9 +27,8 @@ Preloading Assets
27
27
28
28
Imagine that your application includes a web page like this:
29
29
30
- .. code-block :: twig
30
+ .. code-block :: html
31
31
32
- {# templates/homepage.html.twig #}
33
32
<!DOCTYPE html>
34
33
<html >
35
34
<head >
@@ -39,7 +38,7 @@ Imagine that your application includes a web page like this:
39
38
</head >
40
39
<body >
41
40
<main role =" main" class =" container" >
42
- {# ... some content here ... #}
41
+ <!-- ... -->
43
42
</main >
44
43
</body >
45
44
</html >
@@ -58,10 +57,10 @@ To do that, first install the WebLink component:
58
57
Now, update the template to use the ``preload() `` Twig function provided by
59
58
WebLink:
60
59
61
- .. code-block :: twig
60
+ .. code-block :: html+ twig
62
61
63
62
<head>
64
- {# ... #}
63
+ <!-- ... -->
65
64
<link rel="stylesheet" href="{{ preload('/app.css') }}">
66
65
</head>
67
66
@@ -72,10 +71,10 @@ requested the HTML page.
72
71
Additionally, according to `the Priority Hints specification `_, you can signal
73
72
the priority of the resource to download using the ``importance `` attribute:
74
73
75
- .. code-block :: twig
74
+ .. code-block :: html+ twig
76
75
77
76
<head>
78
- {# ... #}
77
+ <!-- ... -->
79
78
<link rel="stylesheet" href="{{ preload('/app.css', { importance: 'low' }) }}">
80
79
</head>
81
80
@@ -102,10 +101,10 @@ improve performance of your applications in production right now.
102
101
If you want to prevent the push but let the browser preload the resource by
103
102
issuing an early separate HTTP request, use the ``nopush `` option:
104
103
105
- .. code-block :: twig
104
+ .. code-block :: html+ twig
106
105
107
106
<head>
108
- {# ... #}
107
+ <!-- ... -->
109
108
<link rel="stylesheet" href="{{ preload('/app.css', { nopush: true }) }}">
110
109
</head>
111
110
@@ -135,12 +134,12 @@ The component also supports sending HTTP links not related to performance and
135
134
any link implementing the `PSR-13 `_ standard. For instance, any
136
135
`link defined in the HTML specification `_:
137
136
138
- .. code-block :: twig
137
+ .. code-block :: html+ twig
139
138
140
139
<head>
141
- {# ... #}
140
+ <!-- ... -->
142
141
<link rel="alternate" href="{{ link('/index.jsonld', 'alternate') }}">
143
- <link rel="stylesheet" href="{{ preload('/app.css', {nopush: true}) }}">
142
+ <link rel="stylesheet" href="{{ preload('/app.css', { nopush: true }) }}">
144
143
</head>
145
144
146
145
The previous snippet will result in this HTTP header being sent to the client:
0 commit comments