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

Add hint to reduce screen flickering #38426

Merged
merged 2 commits into from
Apr 10, 2023
Merged

Add hint to reduce screen flickering #38426

merged 2 commits into from
Apr 10, 2023

Conversation

markdumay
Copy link
Contributor

@markdumay markdumay commented Apr 8, 2023

Description

Add a hint to the Bootstrap docs to include the JavaScript that controls the site's color mode near the top of the page.

Motivation & Context

The provided JavaScript example allows users to select the desired color mode (e.g. Light, Dark, or Auto) for their site. The preferred state is then stored as a user preference. It is considered a good practice to defer the loading of JavaScript files to improve the site responsiveness. However, including this particular JavaScript at the bottom of the page may result in screen flickering during reloading of the site.

Benjamin Koltes has written a blog post that illustrates the problem in more detail. To prevent the screen flickering when using Bootstrap's color mode, it is suggested to treat the provided JavaScript example as a critical resource. This can be done by including or embedding the script in the <head> of the page or close to the opening <body> statement.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

Related issues

N/A

@mdo mdo merged commit b000f2a into twbs:main Apr 10, 2023
13 checks passed
@markdumay markdumay deleted the color-mode-hint branch April 10, 2023 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants