In #4928 slimmer is being removed from frontend. Somehow this caused travel-advice.js to break, which is the filter search used on https://www.gov.uk/foreign-travel-advice - it lives in the <head> but after removing slimmer it could no longer find the DOM element that it targets. In the PR we've moved the JS to the end of the <body> so that the DOM element exists when the JS is run, but ideally this code should be a GOVUK Module so that it doesn't have to sit at the end of the DOM and can be run asynchronously.
As an alternative, I did briefly look at adding DOMContentLoaded to the JS, but this caused one of the Rails test that executed JS to break - I assume that test doesn't fire DOMContentLoaded so the JS wasn't running. Maybe DOMContentLoaded could work as an alternative fix if the event can be fired within the test.
In #4928
slimmeris being removed fromfrontend. Somehow this causedtravel-advice.jsto break, which is the filter search used on https://www.gov.uk/foreign-travel-advice - it lives in the<head>but after removingslimmerit could no longer find the DOM element that it targets. In the PR we've moved the JS to the end of the<body>so that the DOM element exists when the JS is run, but ideally this code should be a GOVUK Module so that it doesn't have to sit at the end of the DOM and can be run asynchronously.As an alternative, I did briefly look at adding
DOMContentLoadedto the JS, but this caused one of the Rails test that executed JS to break - I assume that test doesn't fireDOMContentLoadedso the JS wasn't running. MaybeDOMContentLoadedcould work as an alternative fix if the event can be fired within the test.