Skip to content

travel-advice.js could be a GOVUK Module #4997

@AshGDS

Description

@AshGDS

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions