Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.

New in Symfony 3.3: WebLink component

Contributed by
Kévin Dunglas
in #22273.

A few weeks ago, we added support for asset preloading with HTTP/2 Push. The feedback was so enthusiastic that we decided to improve and expand this feature. In fact, we decided to create a whole new component for it: WebLink.

This new component manages links between resources, not only assets; advising browsers to preload and prefetch resources through HTTP and HTTP/2 pushes. The component implements these specifications: HTML5 Links, Preload, and Resource Hints

All these new features can be used via several Twig functions:

  • link(), adds the Link HTTP header;
  • preload(), preload resources (not only assets);
  • dns_prefetch(), resolves a resource origin as early as possible;
  • preconnect(), initiates a early connection to a resource (including DNS resolution, TCP handshake, and TLS negotiation);
  • prefetch(), indicates to the client that it should prefetch the given resource;
  • prerender(), indicates to the client that it should prerender the given resource.

Unlike the previous preloading feature, this component is not only useful for web assets. Being a standalone component means that it can also be used for example to replace resource embedding by HTTP/2 pushes in your APIs.

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


Javier, after adding this WebLink component in composer, what is the way to enable the Twig functions in config.yml ?
Ok I guess need to activate it in config.yml:
enabled: true

And then add the extension in services :
class: Symfony\Bridge\Twig\Extension\WebLinkExtension
arguments: ["@request_stack"]
- { name: twig.extension }
@Martin, since we're talking about Symfony 3.3, you can even use the new service definition method:

arguments: ["@request_stack"]
- { name: twig.extension }
@Martin @Stephan Or even better yet :

arguments: ["@request_stack"]
tags: ["twig.extension"]
@Dorian Villet

Or even even better yet:

autoconfigure: true

arguments: ["@request_stack"]


Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.