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

Defer prototype application.js to load after plugin scripts #2359

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Oct 9, 2023

This PR switches application.js to <script type"module"> to fix:

This change defers script load by default and also ensures:

  1. ES module import { Accordion } from syntax support in GOV.UK Frontend v5
  2. Load order compatibility with other plugins that update to ES modules

Browser support

This follows GOV.UK Frontend to protect browsers without ES6 modules support from script errors, such as:

  • Internet Explorer 11
  • Edge 15
  • Chrome 60
  • Firefox 59
  • Safari 9

@colinrotherham colinrotherham linked an issue Oct 9, 2023 that may be closed by this pull request
@colinrotherham colinrotherham changed the title Update application.js to <script type"module"> Defer prototype application.js to load after plugin scripts Oct 9, 2023
BenSurgisonGDS
BenSurgisonGDS previously approved these changes Oct 9, 2023
This enables ES module imports by default:

```
import { Component } from '/plugin-assets/plugin-name/example.js'
```

Since GOV.UK Frontend v5 also uses `<script type="module">`, this change also ensures application.js executes after `window.GOVUKFrontend` is ready
@colinrotherham
Copy link
Contributor Author

Moved the CHANGELOG entry into Unreleased

nataliecarey
nataliecarey previously approved these changes Oct 10, 2023
Base automatically changed from frontend-v5-deprecated to main October 11, 2023 09:18
@colinrotherham colinrotherham dismissed stale reviews from nataliecarey and BenSurgisonGDS October 11, 2023 09:18

The base branch was changed.

@colinrotherham colinrotherham merged commit 67c8b7f into main Oct 11, 2023
27 checks passed
@colinrotherham colinrotherham deleted the application-script-module branch October 11, 2023 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plugin scripts with "type": "module" run too late
3 participants