You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next you must add the `\JustBetter\Http3EarlyHints\Middleware\AddHttp3EarlyHints`-middleware to the kernel. Adding it to the web group is recommeneded as API's do not have assets to push.
@@ -43,11 +61,42 @@ default behaviour is adding the link headers to the 200 response which e.g. [Clo
43
61
When you route a request through the `AddHttp3EarlyHints` middleware, the response is scanned for any `link`, `script` or `img` tags that could benefit from being loaded using Early Hints.
44
62
These assets will be added to the `Link` header before sending the response to the client. Easy!
45
63
46
-
**Note:** To push an image asset, it must have one of the following extensions: `bmp`, `gif`, `jpg`, `jpeg`, `png`, `tiff` or `svg` and not have `loading="lazy"`
64
+
**Note:** To push an image asset, it must have one of the following extensions: `bmp`, `gif`, `jpg`, `jpeg`, `png`, `svg`, `tiff` or `webp` and not have `loading="lazy"`
47
65
48
66
### Advanced usage
49
67
50
-
If the automatic detection isn't enough for you, you can listen for GenerateEarlyHints events, and manually add new links.
68
+
If the automatic detection isn't enough for you, you can listen for the `GenerateEarlyHints` event, and manually add/remove/change new links.
69
+
70
+
#### Detailed default behaviour
71
+
72
+
The information on [usage](#usage) is simplified, there are many checks done to make sure we don't preload the wrong things.
73
+
74
+
Early hints only support rel=preconnect and rel=preload [source](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103#browser_compatibility)
75
+
76
+
We automatically transform any rel that is not `preconnect` or `preload` into `preload`, so your `<link rel="modulepreload" href="app.js">` will get preloaded with early hints. And get more detailed information once your server starts sending it's response.
77
+
78
+
##### Link
79
+
80
+
Any link elements which do **not** have rel=
81
+
- icon
82
+
- canonical
83
+
- manifest
84
+
- alternative
85
+
86
+
##### Script
87
+
88
+
Script tags will automatically get preloaded **if** it does not have an `async` or `defer` attribute attached to it.
89
+
90
+
##### Img
91
+
92
+
Img tags will automatically get preloaded when it does not have `loading="lazy"` and it does not exist within a picture tag.
93
+
94
+
If it is within a picture tag we may be dealing with mutliple `srcset`s or `type`s, and thus cannot determine which file the browser will need.
95
+
So we will not preload these images.
96
+
97
+
##### Object
98
+
99
+
If your html object tag contains `data=""` it will preload it.
0 commit comments