@@ -104,18 +104,18 @@ can do most of the work for you:
104
104
<!-- Renders a link tag (if your module requires any CSS)
105
105
<link rel="stylesheet" href="/build/app.css"> -->
106
106
{% endblock %}
107
- </head>
108
- <body>
109
- <!-- ... -->
110
107
111
108
{% block javascripts %}
112
109
{{ encore_entry_script_tags('app') }}
113
110
114
111
<!-- 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 -->
117
115
{% endblock %}
118
- </body>
116
+ </head>
117
+
118
+ <!-- ... -->
119
119
</html>
120
120
121
121
.. _encore-entrypointsjson-simple-description :
@@ -135,11 +135,14 @@ If you're *not* using Symfony, you can ignore the ``entrypoints.json`` file and
135
135
point to the final, built file directly. ``entrypoints.json `` is only required for
136
136
some optional features.
137
137
138
- .. versionadded :: 0.21 .0
138
+ .. versionadded :: 1.9 .0
139
139
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.
143
146
144
147
Requiring JavaScript Modules
145
148
----------------------------
@@ -355,3 +358,4 @@ Encore supports many more features! For a full list of what you can do, see
355
358
356
359
.. _`Encore's index.js file` : https://github.com/symfony/webpack-encore/blob/master/index.js
357
360
.. _`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