Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview v5: Add explanation that individual initialisation will throw errors #352

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/importing-css-assets-and-javascript/index.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ Then import the JavaScript file before the closing `</body>` tag of your HTML pa
</body>
```

Errors from components will be logged in the browser's console.

For example, when:

* GOV.UK Frontend is not supported in the current browser
* Component templates have missing changes from our release notes
* Component JavaScript configuration does not match our documentation

colinrotherham marked this conversation as resolved.
Show resolved Hide resolved
You should check your application works without errors or some components will not work correctly.
colinrotherham marked this conversation as resolved.
Show resolved Hide resolved

#### Select and initialise an individual component

You can select and initialise a specific component by using its `data-module` attribute. For example, use `govuk-radios` to initialise the first radio component on a page:
Expand All @@ -176,6 +186,8 @@ You can select and initialise a specific component by using its `data-module` at
</script>
```

When initialised individually, errors are thrown rather than logged. You must check your application works without errors or some components will not work correctly.

### Import JavaScript using a bundler

If you decide to import using a bundler, we recommend you use `import` to only import the JavaScript for components you're using in your service. For example:
Expand Down