Skip to content

Commit 2a1c042

Browse files
Update guidance for <script type="module">
1 parent 838e253 commit 2a1c042

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
@@ -66,19 +66,19 @@ Add the following JavaScript to the top of the `<body>` section of your page tem
6666

6767
### Option 1: Include compiled JavaScript
6868

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

71-
> 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.
71+
> 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.
7272
7373
You might wish to copy the file into your project or reference it straight from node_modules.
7474

7575
```html
76-
<script src="path-to-assets/nhsuk.min.js" defer></script>
76+
<script src="path-to-assets/nhsuk.min.js" type="module"></script>
7777
</head>
7878
```
7979

8080
```html
81-
<script src="node_modules/nhsuk-frontend/dist/nhsuk.min.js" defer></script>
81+
<script src="node_modules/nhsuk-frontend/dist/nhsuk.min.js" type="module"></script>
8282
</head>
8383
```
8484

0 commit comments

Comments
 (0)