question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Components failing initialisation break due to `.js-enabled` styles

See original GitHub issue
js-blocked

It 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.

https://github.com/alphagov/govuk_template/blob/master/source/views/layouts/govuk_template.html.erb#L113

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:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
edwardhorsfordcommented, Mar 15, 2019

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.

0reactions
colinrotherhamcommented, Dec 13, 2022

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:

  1. JavaScript off
  2. JavaScript on but crashed
  3. JavaScript on but skipped checks
  4. JavaScript on but took too long

(Where “skipped checks” could be an early return false after a query selector check fails)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found