Skip to content

Commit

Permalink
Move Javascript modules to es6-components
Browse files Browse the repository at this point in the history
To prevent browsers evaluating JS that isn't supported, components that
contain code from govuk-frontend have been moved to a separate file
`es6-components.js` which is included in `application.html.erb` as a
script tag with `type="module"`.
  • Loading branch information
patrickpatrickpatrick authored and MartinJJones committed Jul 5, 2024
1 parent 0b7cb78 commit ffb32a3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//= link application.js
//= link es6-components.js

//= link_tree ../builds
2 changes: 0 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
//= require govuk_publishing_components/lib
//= require govuk_publishing_components/components/details
//= require govuk_publishing_components/components/error-summary
//= require govuk_publishing_components/components/radio
2 changes: 2 additions & 0 deletions app/assets/javascripts/es6-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//= require govuk_publishing_components/components/error-summary
//= require govuk_publishing_components/components/radio
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@
<body class="govuk-template__body">
<%= yield :body %>
<%= javascript_include_tag 'application' %>
<%= javascript_include_tag "es6-components", type: "module" %>
</body>
</html>

0 comments on commit ffb32a3

Please sign in to comment.