This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bridge/Twig/Tests
Fabien Potencier 6d77cdfd65 feature #21478 [Asset] Add support for preloading with links and HTTP/2 push (dunglas)
This PR was squashed before being merged into the 3.3-dev branch (closes #21478).

Discussion
----------

[Asset] Add support for preloading with links and HTTP/2 push

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | todo

Allows compatible clients to preload mandatory assets like scripts, stylesheets or images according to [the "preload" working draft of the W3C](https://www.w3.org/TR/preload/).
Thanks to this PR, Symfony will automatically adds `Link` HTTP headers with a `preload` relation for mandatory assets.  If an intermediate proxy supports HTTP/2 push, it will convert preload headers. For instance [Cloudflare supports this feature](https://blog.cloudflare.com/using-http-2-server-push-with-php/).

It dramatically increases pages speed and make the web greener because only one TCP connection is used to fetch all mandatory assets (decrease servers and devices loads, improve battery lives).

Usage:

Updated version:

```html
<html>
    <body>
    Hello
    <script src="{{ preload(asset('/scripts/foo.js'), 'script') }}"></script>
    </body>
</html>
```

~~First proposal:~~

```html
<html>
    <body>
    Hello
    <script src="{{ preloaded_asset('/scripts/foo.js', 'script') }}"></script>
    </body>
</html>
```

- [x] Add tests

Commits
-------

7bab21700d [Asset] Add support for preloading with links and HTTP/2 push
2017-02-19 14:57:15 -08:00
..
Command Merge branch '2.8' into 3.2 2017-02-18 18:28:00 +01:00
Extension feature #21478 [Asset] Add support for preloading with links and HTTP/2 push (dunglas) 2017-02-19 14:57:15 -08:00
Fixtures/extractor [Translation][Extractor] Allow extracting an array of files besides extracting a directory 2015-03-27 07:53:09 +01:00
Node Merge branch '2.8' into 3.2 2017-02-18 18:28:00 +01:00
NodeVisitor Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
TokenParser Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
Translation Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
AppVariableTest.php Merge branch '2.8' into 3.2 2017-02-18 18:28:00 +01:00
TwigEngineTest.php Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00