The Wayback Machine - https://web.archive.org/web/20221101140607/https://github.com/symfony/symfony/discussions/47782
Skip to content

How to get the defer tag on encore_scripts <script #47782

Unanswered
neilf184 asked this question in Q&A
Discussion options

I've been attempting to upgrade by webpack-encore from 0.31.1 to 1.8.2 (wepack 4 to webpack 5) so as to be able to have the 'defer' tag included on the <script> html elements for encore_scripts. Having finally got the application to build (npm run dev) with webpack 1.8.2 I'm disappointed to see that the 'defer' tags are not being generated.

I tried installing webpack-encore-bundle on top of my existing packages, as per article here . This has created a webpack_encore.yaml file which includes "script_attributes: defer: true" but this has made do difference. Presumably this is because webpack is using my webpack.config.js file and ignoring webpack_encore.yaml.

Is there some way of configuring this in webpack.config.js, how can I get this working?

You must be logged in to vote

Replies: 1 suggested answer · 6 replies

Comment options

defer get added if you use encore_entry_script_tags in your Twig template. This function comes with the WebpackEncoreBundle so you probably don’t call it since you did not install the bundle before.

You must be logged in to vote
6 replies
@MatTheCat
Comment options

Did you follow https://github.com/symfony/webpack-encore-bundle#webpackencorebundle-symfony-integration-with-webpack-encore to install the WebpackEncoreBundle? Seems like something is missing.

@neilf184
Comment options

Sorry for the delay, holiday & illness intervened. Yes, followed all instructions.

@MatTheCat
Comment options

Please provide a reproducer then

@neilf184
Comment options

Sorry, not sure what that is/how to provide

@MatTheCat
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.