remove listener for DOMContentLoaded #9
Merged
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.
Proposed changes
Previously we were attaching Features API functions to the dom within a DOMContentLoaded listener callback. This was delaying access to the methods and causing the bluehost plugin to break in some scenarios (especially with other plugins being active). The API doesn't need the DOM content to be loaded before attaching the methods, as all the values it needs are localized in the module already and attached to the page. So this removes the DOMContentLoaded listener and callback. We can just add it to the dom as soon as the features script loads and since it is required by the plugin script it will be available.
The features API is used in the routes file of the app when it determines which pages to add to the navigation. If performance or staging features are disabled, they will not be added to the nav. Though this functionality could be updated, by displaying a link which would allow a user to enable the feature. This features API still doesn't need to be attached to the listner callback like it was.
I tested this change on a live site and with the following plugins also active (which have all been shown to cause issues):
Also see: https://jira.newfold.com/browse/PRESS1-402
Type of Change
Checklist
Further comments