@@ -104,18 +104,18 @@ can do most of the work for you:
104104 <!-- Renders a link tag (if your module requires any CSS)
105105 <link rel="stylesheet" href="/build/app.css"> -->
106106 {% endblock %}
107- </head>
108- <body>
109- <!-- ... -->
110107
111108 {% block javascripts %}
112109 {{ encore_entry_script_tags('app') }}
113110
114111 <!-- Renders app.js & a webpack runtime.js file
115- <script src="/build/runtime.js"></script>
116- <script src="/build/app.js"></script> -->
112+ <script src="/build/runtime.js" defer></script>
113+ <script src="/build/app.js" defer></script>
114+ See note below about the "defer" attribute -->
117115 {% endblock %}
118- </body>
116+ </head>
117+
118+ <!-- ... -->
119119 </html>
120120
121121.. _encore-entrypointsjson-simple-description :
@@ -135,11 +135,14 @@ If you're *not* using Symfony, you can ignore the ``entrypoints.json`` file and
135135point to the final, built file directly. ``entrypoints.json `` is only required for
136136some optional features.
137137
138- .. versionadded :: 0.21 .0
138+ .. versionadded :: 1.9 .0
139139
140- The ``encore_entry_link_tags() `` comes from WebpackEncoreBundle and relies
141- on a feature in Encore that was first introduced in version 0.21.0. Previously,
142- the ``asset() `` function was used to point directly to the file.
140+ The ``defer `` attribute on the ``script `` tags delays the execution of the
141+ JavaScript until the page loads (similar to putting the ``script `` at the
142+ bottom of the page). The ability to always add this attribute was introduced
143+ in WebpackEncoreBundle 1.9.0 and is automatically enabled in that bundle's
144+ recipe in the ``config/packages/webpack_encore.yaml `` file. See
145+ `WebpackEncoreBundle Configuration `_ for more details.
143146
144147Requiring JavaScript Modules
145148----------------------------
@@ -355,3 +358,4 @@ Encore supports many more features! For a full list of what you can do, see
355358
356359.. _`Encore's index.js file` : https://github.com/symfony/webpack-encore/blob/master/index.js
357360.. _`ECMAScript 6 modules` : https://hacks.mozilla.org/2015/08/es6-in-depth-modules/
361+ .. _`WebpackEncoreBundle Configuration` : https://github.com/symfony/webpack-encore-bundle#configuration
0 commit comments