Register only one DOMContentLoaded event listener in onDOMContentLoaded#34158
Merged
Register only one DOMContentLoaded event listener in onDOMContentLoaded#34158
DOMContentLoaded event listener in onDOMContentLoaded#34158Conversation
Member
|
Seems fine by me. (You may could add a test) |
GeoSot
approved these changes
Jun 1, 2021
6760d0a to
7278a2b
Compare
Contributor
Author
|
@GeoSot Changed the implementation so it wouldn't add an event listener when the function isn't called during |
GeoSot
approved these changes
Jun 2, 2021
Member
|
@rohit2sharma95 give it a look, if you like, for a second opinion |
rohit2sharma95
approved these changes
Jun 2, 2021
Contributor
rohit2sharma95
left a comment
There was a problem hiding this comment.
Good work @alpadev 🥇
7278a2b to
9c9bb7c
Compare
…aded function Instead of adding an event listener everytime the utility function is called, cache the callbacks and execute them all at once.
d4dd813 to
99e448e
Compare
Contributor
Author
|
@XhmikosR removed the IIFE as requested |
mdo
approved these changes
Jun 14, 2021
DOMContentLoaded event listener in onDOMContentLoaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #34103
Since #34114 is more focused around changing the way we register our components with jQuery, this PR is changing the
onDOMContentLoadedutility function, to make use of an array to cache callbacks (while the document is loading) and execute them all at once. Therefore we register only oneDOMContentLoadedevent listener instead of one for every call to the function.