Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9345cd3

Browse files
committedAug 16, 2019
minor #12179 Add a note for preload asset (Antoine Lamirault)
This PR was merged into the 3.4 branch. Discussion ---------- Add a note for preload asset This PR add a note about how to preload asset in Sf 3.4. Indeed it was not explained. There was just a symfony blog article about it : https://symfony.com/blog/new-in-symfony-3-3-asset-preloading-with-http-2-push Moreover `preload('build/style.css', { as: 'style' })` generates a good link in Sf4 but not in sf3 (relative instead of absolute). I think is confusing. I hope it can help other developers. Commits ------- d9b88d7 Add a note for preload asset
2 parents 37a762c + d9b88d7 commit 9345cd3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

‎web_link.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ If you reload the page, the perceived performance will improve because the
6969
server responded with both the HTML page and the CSS file when the browser only
7070
requested the HTML page.
7171

72+
.. note::
73+
74+
You can preload an asset by wrapping it with the ``preload()`` function
75+
76+
.. code-block:: html+twig
77+
78+
<head>
79+
{# ... #}
80+
<link rel="stylesheet" href="{{ preload(asset('build/app.css')) }}">
81+
</head>
82+
7283
Additionally, according to `the Priority Hints specification`_, you can signal
7384
the priority of the resource to download using the ``importance`` attribute:
7485

0 commit comments

Comments
 (0)
Please sign in to comment.