Skip to content

Conversation

circlecube
Copy link
Member

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):

  • WooCommerce
  • WonderCart
  • YITH Payments
  • GA Monster Insights

Also see: https://jira.newfold.com/browse/PRESS1-402

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@circlecube circlecube requested review from wpscholar and wpalani June 20, 2024 19:04
@circlecube circlecube self-assigned this Jun 20, 2024
Copy link
Member

@wpscholar wpscholar left a comment

Choose a reason for hiding this comment

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

Thanks @circlecube !

@circlecube circlecube merged commit 0424ca6 into main Jun 20, 2024
@circlecube circlecube deleted the fix/event-listener-race branch June 20, 2024 19:10
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

Successfully merging this pull request may close these issues.

2 participants