Components failing initialisation break due to `.js-enabled` styles
See original GitHub issueIt is possible for components to be in a completely broken state if the user has JavaScript enabled but the GOV.UK Frontend bundle fails to download.
Previously we detected the presence of GOV.UK
globally on window, but we removed this since we could not be sure if people would be using bundlers which will not output a global.
We could consider, injecting a global whenever a component is loaded that can remove js-enabled.
Potentially something like:
if (not already injected) {
window.___GOVUKFrontendComponentInitialised___
}
// tabs.js
import 'inject-global-initialised'
// only injects if not already injected before
inject()
// rest of tabs code here
// template.njk
<script>if(!window.___GOVUKFrontendComponentInitialised___) { // remove js-enabled }</script>
</body>
https://trello.com/c/oRDkiAz9/1448-frontend-components-appeared-styled-when-js-blocked
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
3 Common Problems with Neural Network Initialization
A common machine learning modelling process goes by (1) weight initialization, (2) forward propagation, (3) loss (or cost) computation, (4) backpropagation, ...
Read more >Weight Initialization in Neural Network, inspired by Andrew Ng
This problem is known as network failing to break symmetry. And not only zero, any constant initialization will produce a poor result.
Read more >Danger of setting all initial weights to zero in Backpropagation
Main problem with initialization of all weights to zero mathematically leads to either the neuron values are zero (for multi layers) or the ......
Read more >Initializing neural networks - DeepLearning.AI
Despite breaking the symmetry, initializing the weights with values (i) too small or (ii) too large leads respectively to (i) slow learning or...
Read more >5.4. Numerical Stability and Initialization
5.4.1.1. Vanishing Gradients¶. One frequent culprit causing the vanishing gradient problem is the choice of the activation function ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We had a similar issue in my service this week. For reasons our service’s js file for IE failed to compile so our service’s js wasn’t available in IE - but we still had the
js-enabled
class. This caused the worst of both worlds - fields with conditional content were hidden and there was no way to get to them.If there are recommended solutions - like testing for a variable I’d be keen to hear them.
Adding a list of scenarios from:
For context: We improved Accordion sections to be visible during page load in https://github.com/alphagov/govuk-frontend/pull/3053 but for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation
We’d like to review similar components load with:
(Where “skipped checks” could be an early
return false
after a query selector check fails)