Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defer always rendered for scripts in src/Asset/TagRenderer.php #103

Closed
lamselli opened this issue Jan 25, 2021 · 2 comments
Closed

defer always rendered for scripts in src/Asset/TagRenderer.php #103

lamselli opened this issue Jan 25, 2021 · 2 comments

Comments

@lamselli
Copy link

In last version, I didn't want my scripts to have "defer" attribute, as I was using old jquery calls inside my rendered page.
But the defer attribute is added even when you set defer to false in config file (webpack_encore.yaml)
script_attributes: defer: false

As a workaround, I had to create a subscriber event to RenderAssetTagEvent to remove the attribute defer if its value is equal to false.

Sorry if I am unclear, but english is not my native language.

@maxhelias
Copy link

maxhelias commented Jan 25, 2021

Maybe an array_filter with a condition on the null value here : https://github.com/symfony/webpack-encore-bundle/blob/main/src/Asset/TagRenderer.php#L183, could be the solution.

@weaverryan
Copy link
Member

Fixed in #113. But also, even before that version, you can remove the defer attribute from the config :)

webpack_encore:
    script_attributes:
-        defer: true

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants