You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(Build): Load modernizr early and non-asynchronously.
Include the modernizr bundle by injecting a script tag. This ensures
modernizr is loaded synchronously and executing early and sets it's
feature detection classes before the layout is done by the browser.
This reverts the breaking change from the previous Patternslib 9.8.0-beta.2
release. The separate modernizr.min.js build file is still kept, but
modernizr is included by the main Patternslib bundle. There is no need
to add another script tag to include modernizr.
You can disable loading of modernizr by setting the following before the
Patternslib bundle.min.js is included:
<script>window.__patternslib_disable_modernizr = true;</script>
Also, the "js" class is set on the HTML root tag when a "no-js" class
was present regardless of the "__patternslib_disable_modernizr" setting.
Since Patternslib 9.0.0-alpha.0 where we introduced webpack module
federation for our bundles, Modernizr is loaded asynchronously and
applying it's CSS classes a tick too late. For example, the change from
the "no-js" to the "js" class was done while the tiles have already been
drawn and visible on the screen, resulting in screen flickering. There
are a number of projects which depend on Modernizr being applied early.
This module adds the `js` class to the HTML root node and loads Modernizr for more feature detection.
4
+
5
+
---
6
+
** Note **
7
+
8
+
If you create own bundles based on Patternslib, you would need to import the `src/core/feature-detection` module for these features to be available.
9
+
10
+
---
11
+
12
+
13
+
## Adding the "js" class for accessibility styles
14
+
15
+
There are situations where web browsers do not have JavaScript available or when it is disabled.
16
+
In situations where no JavaScript is available you might want to show certain elements where in JavaScript situations you might want to hide them until a JavaScript functionality is showing them.
17
+
18
+
In the Media Query Level 5 specification there is a CSS media feature to detect JavaScript via a [`scripting` at-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/scripting).
19
+
But at time of this writing this is [not available in any of the major browsers](https://caniuse.com/mdn-css_at-rules_media_scripting).
20
+
21
+
Therefore Patternslib adds a `js` class to the HTML root node, if the HTML root node already has a `no-js` class.
22
+
The `js` class is set very early before any browser layout is done if you include the Patternslib script in the HEAD of your site.
0 commit comments