Skip to content

Commit 942d9bf

Browse files
Update guidance for <script type="module">
1 parent 2e6524a commit 942d9bf

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/_templates/layout.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<link href="https://assets.nhs.uk/fonts/FrutigerLTW01-55Roman.woff2" type="font/woff2" rel="preload" as="font" crossorigin>
99
<link href="https://assets.nhs.uk/fonts/FrutigerLTW01-65Bold.woff2" type="font/woff2" rel="preload" as="font" crossorigin>
1010
<link href="{{ baseUrl }}stylesheets/nhsuk-{{ version }}.min.css" rel="stylesheet">
11-
<script src="{{ baseUrl }}javascripts/nhsuk-{{ version }}.min.js" defer></script>
11+
<script src="{{ baseUrl }}javascripts/nhsuk-{{ version }}.min.js" type="module"></script>
1212
{% endblock %}
1313

1414
{# Turn the header and footer off #}

docs/installation/installing-compiled.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ If you require any of this functionality, you should [install using npm](/docs/i
2929
<link rel="stylesheet" href="css/nhsuk-[latest version].min.css">
3030

3131
<!-- Scripts -->
32-
<script src="js/nhsuk-[latest version].min.js" defer></script>
32+
<script src="js/nhsuk-[latest version].min.js" type="module"></script>
3333

3434
<!-- Favicons -->
3535
<link rel="shortcut icon" href="assets/favicons/favicon.ico" type="image/x-icon">

docs/installation/installing-with-npm.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,19 @@ Add the following JavaScript to the top of the `<body>` section of your page tem
7979

8080
### Option 1: Include compiled JavaScript
8181

82-
Include the `node_modules/nhsuk-frontend/dist/nhsuk.min.js` script in the `<head>` of your page using the `defer` attribute.
82+
Include the `node_modules/nhsuk-frontend/dist/nhsuk.min.js` script in the `<head>` of your page using the `type="module"` attribute.
8383

84-
> The defer attribute is used for performance benefits as the browser loads the JavaScript file as soon as possible, due to it being in the `<head>`, but will not run until after the page has loaded.
84+
> The `type="module"` attribute stops Internet Explorer 11 and other older browsers running the JavaScript, which relies on features older browsers might not support and could cause errors. The script will be loaded as soon as possible, due to it being in the `<head>`, but will not run until after the page has loaded.
8585
8686
You might wish to copy the file into your project or reference it straight from node_modules.
8787

8888
```html
89-
<script src="path-to-assets/nhsuk.min.js" defer></script>
89+
<script src="path-to-assets/nhsuk.min.js" type="module"></script>
9090
</head>
9191
```
9292

9393
```html
94-
<script src="node_modules/nhsuk-frontend/dist/nhsuk.min.js" defer></script>
94+
<script src="node_modules/nhsuk-frontend/dist/nhsuk.min.js" type="module"></script>
9595
</head>
9696
```
9797

0 commit comments

Comments
 (0)