Add hint to reduce screen flickering #38426
Merged
+1
−1
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.
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
Checklist
npm run lint
)Live previews
Related issues
N/A