Skip to content

Commit

Permalink
Merge branch '7.2' into 7.3
Browse files Browse the repository at this point in the history
* 7.2:
  [WebLink] Minor reword
  remove installation repetition in weblink
  • Loading branch information
javiereguiluz committed Dec 26, 2024
2 parents be8b28f + e7fdf18 commit dfeaef1
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions web_link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,14 @@ Imagine that your application includes a web page like this:
</body>
</html>

Following the traditional HTTP workflow, when this page is served browsers will
make one request for the HTML page and another request for the linked CSS file.
However, thanks to HTTP/2 your application can start sending the CSS file
contents even before browsers request them.

To do that, first install the WebLink component:

.. code-block:: terminal
$ composer require symfony/web-link
Now, update the template to use the ``preload()`` Twig function provided by
WebLink. The `"as" attribute`_ is mandatory because browsers need it to apply
correct prioritization and the content security policy:
In a traditional HTTP workflow, when this page is loaded, browsers make one
request for the HTML document and another for the linked CSS file. However,
with HTTP/2, your application can send the CSS file's contents to the browser
before it requests them.

To achieve this, update your template to use the ``preload()`` Twig function
provided by WebLink. Note that the `"as" attribute`_ is required, as browsers use
it to prioritize resources correctly and comply with the content security policy:

.. code-block:: html+twig

Expand Down

0 comments on commit dfeaef1

Please sign in to comment.