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

improvement(server): Allow setting async/defer via extraProps #526

Closed
wants to merge 3 commits into from

Conversation

jackyef
Copy link
Contributor

@jackyef jackyef commented Feb 12, 2020

Summary

Solving #337

Default: async: true, defer: false

Scenarios:

  • extractor.getScriptTags({ defer: true }) will return <script async defer ...></script> (because async is true by default)
  • extractor.getScriptTags({ async: true }) will return <script async ...></script>
  • extractor.getScriptTags({ async: false, defer: true }) will return <script defer ...></script>
  • extractor.getScriptTags() will return <script async ...></script> to keep the default behaviour, preventing breaking change.

Using both async and defer together might have a valid use case as explained here

Test plan

Tests are added to ChunkExtractor.test.js

@jackyef jackyef requested a review from gregberge February 12, 2020 11:36
Copy link
Owner

@gregberge gregberge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • async should be true by default
  • The micro-optimization reduces the code lisibility (and probably does not change anything)
  • The method getRequiredChunksScriptTag should support async and defer like others, the difference of options should be coded in getScriptTags and getScriptElements.
  • Documentation is missing

@jackyef
Copy link
Contributor Author

jackyef commented Feb 17, 2020

The method getRequiredChunksScriptTag should support async and defer like other

One question about this though, does async/defer have impact when the script is inline? (Which is the case of getRequiredChunksScriptTag) @gregberge

@stale
Copy link

stale bot commented Apr 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 17, 2020
@jackyef
Copy link
Contributor Author

jackyef commented Apr 18, 2020

@gregberge Hi, are we really deciding on this as wontfix?

@stale stale bot removed the wontfix label Apr 18, 2020
@ArgonAlex
Copy link

Just want to express my desire for this functionality. Right now I'm resorting to hackily string replacing async with defer.

@suhanw
Copy link

suhanw commented Jun 13, 2020

Would love this feature too

@stale
Copy link

stale bot commented Aug 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 12, 2020
@theKashey
Copy link
Collaborator

Stalebot go away

@stale stale bot removed the wontfix label Aug 12, 2020
@stale
Copy link

stale bot commented Oct 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@qingzhou729
Copy link

Would love this feature too!!

1 similar comment
@qingzhou729
Copy link

Would love this feature too!!

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

Successfully merging this pull request may close these issues.

6 participants