symfony-docs icon indicating copy to clipboard operation
symfony-docs copied to clipboard

[WebLink] Confusing explanation of asset preloading

Open javiereguiluz opened this issue 11 months ago • 4 comments

In my opinion, this page is confusing: https://symfony.com/doc/current/web_link.html

There are repeated explanations about asset preloading and they seem to contradict each other:

javiereguiluz avatar Jan 10 '25 19:01 javiereguiluz

What we need to clarify here is:

  • What do browsers need for this feature to work?
  • What must servers do to enable this feature?
  • Related: which servers (and SasS services like Cloudflare) do that for you automatically?
  • What do you need to do in your Twig templates? There are some scenarios:
    • (1) when using only WebLink;
    • (2) When also using AssetMapper;
    • (3) When also using Webpack Encore (is it compatible too?)

javiereguiluz avatar Jan 13 '25 10:01 javiereguiluz

@javiereguiluz i’ve experience this as well recently on a project when reading doc and blog and code @smnandre friendly ping, this relates to our discussion recently on https://github.com/symfony/symfony/issues/59392

To me there is room for doc update indeed, perhaps as well with some graph?

94noni avatar Jan 15 '25 20:01 94noni

Let's ping our friend @dunglas to see if he can explain this to us and then we can update the docs based on those comments. Thanks.

javiereguiluz avatar Jan 17 '25 07:01 javiereguiluz

Can already answer some of your comments here:

Regarding the contradiction, we may use a better example in the second one, for instance preloading a webfont that will be used in the page but declared in a CSS file.

First comment can be removed i think. It was certainely written on good intention: avoiding someone thinking just using the preload tag will load it's CSS. But in the end i agree it may create more doubts than help.

We can totally write all the answers for the questions you asked, but I also think we should be transparent on the expected impacts, and maybe list the other things to do to achieve better performance (as i'm afraid not everyone is already aware of the first things to check... and would not want people to believe they have to handle this in priority when assets size, lazy loading, cache, should (maybe?) be done before any header optimization)

smnandre avatar Jan 18 '25 00:01 smnandre