Skip to content

Conversation

@amyleadem
Copy link
Contributor

@amyleadem amyleadem commented May 6, 2022

Summary

uswds-init is better at suppressing FOUC. We updated the uswds-init script's event listener to target window from document. This assures that the page's JavaScript is fully loaded before we remove the loadingClass that suppresses the open banner. The banner should no longer flash open.

Related Issue

Closes uswds/uswds-site#1559

Solution

Changed the target of the event listener from document to window in uswds-init.js. Testing shows that window load appears to finish after document load. By moving targets, we ensure the page is fully loaded prior to removing the loadingClass.

Testing and review

To see the fix in action, check out this USWDS-site preview link ➡️

Notes

Additional information

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

@amyleadem amyleadem requested a review from mejiaj May 9, 2022 13:50
@amyleadem amyleadem marked this pull request as ready for review May 9, 2022 13:52
@amyleadem amyleadem changed the title USWDS - Repair uswds-init load issues USWDS - Repair uswds-init load flashing May 9, 2022
Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!

@mejiaj mejiaj requested a review from thisisdano May 9, 2022 16:59
@thisisdano thisisdano linked an issue May 9, 2022 that may be closed by this pull request
Copy link
Contributor

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

Excellent, smart fix

@thisisdano thisisdano merged commit 3e8660c into develop May 10, 2022
@thisisdano thisisdano deleted the al-uswds-init-load branch May 10, 2022 03:34
@thisisdano thisisdano mentioned this pull request Jun 17, 2022
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.

USWDS Init is no longer effectively suppressing FOUC Flash of unstyled content on Federalist previews

4 participants