Skip to content

Commit

Permalink
improve web_link
Browse files Browse the repository at this point in the history
  • Loading branch information
garak committed Sep 9, 2024
1 parent da99ac7 commit 68461b9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions web_link.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ correct prioritization and the content security policy:

<head>
<!-- ... -->
<link rel="preload" href="{{ preload('/app.css', { as: 'style' }) }}">
<link rel="preload" href="{{ preload('/app.css', {as: 'style'}) }}" as="style">
<link rel="stylesheet" href="/app.css">
</head>

If you reload the page, the perceived performance will improve because the
Expand All @@ -74,7 +75,8 @@ requested the HTML page.

<head>
<!-- ... -->
<link rel="preload" href="{{ preload(asset('build/app.css')) }}">
<link rel="preload" href="{{ preload(asset('build/app.css')) }}" as="style">
<!-- ... -->
</head>

Additionally, according to `the Priority Hints specification`_, you can signal
Expand All @@ -84,7 +86,8 @@ the priority of the resource to download using the ``importance`` attribute:

<head>
<!-- ... -->
<link rel="preload" href="{{ preload('/app.css', { as: 'style', importance: 'low' }) }}">
<link rel="preload" href="{{ preload('/app.css', {as: 'style', importance: 'low'}) }}" as="style">
<!-- ... -->
</head>

How does it work?
Expand All @@ -108,7 +111,8 @@ issuing an early separate HTTP request, use the ``nopush`` option:

<head>
<!-- ... -->
<link rel="preload" href="{{ preload('/app.css', { as: 'style', nopush: true }) }}">
<link rel="preload" href="{{ preload('/app.css', {as: 'style', nopush: true}) }}" as="style">
<!-- ... -->
</head>

Resource Hints
Expand Down Expand Up @@ -142,7 +146,8 @@ any link implementing the `PSR-13`_ standard. For instance, any
<head>
<!-- ... -->
<link rel="alternate" href="{{ link('/index.jsonld', 'alternate') }}">
<link rel="preload" href="{{ preload('/app.css', { as: 'style', nopush: true }) }}">
<link rel="preload" href="{{ preload('/app.css', {as: 'style', nopush: true}) }}" as="style">
<!-- ... -->
</head>

The previous snippet will result in this HTTP header being sent to the client:
Expand Down

0 comments on commit 68461b9

Please sign in to comment.