diff --git a/source/importing-css-assets-and-javascript/index.html.md.erb b/source/importing-css-assets-and-javascript/index.html.md.erb index 173b4cd0..680fdc3e 100644 --- a/source/importing-css-assets-and-javascript/index.html.md.erb +++ b/source/importing-css-assets-and-javascript/index.html.md.erb @@ -162,6 +162,14 @@ Then import the JavaScript file before the closing `` tag of your HTML pa ``` +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 + #### 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: @@ -176,6 +184,12 @@ You can select and initialise a specific component by using its `data-module` at ``` +When initialised individually, errors are thrown rather than logged. +This will stop the execution of the script and you'll need to either: + +* fix what causes the error +* use a [`try/catch` block](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) to change the behaviour of your code in reaction to the error + ### 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: