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 committed Nov 16, 2023
1 parent 10d0755 commit a193195
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//= link_tree ../images
//= link application.js
//= link es6-components.js
//= link webchat.js
//= link application.css
//= link components/_back-to-top.css
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
//= require govuk_publishing_components/lib
//= require govuk_publishing_components/components/accordion
//= require govuk_publishing_components/components/details
//= require govuk_publishing_components/components/error-summary
//= require govuk_publishing_components/components/govspeak
//= require govuk_publishing_components/components/image-card
//= require govuk_publishing_components/components/intervention
//= require govuk_publishing_components/components/metadata
//= require govuk_publishing_components/components/print-link
//= require govuk_publishing_components/components/radio
//= require govuk_publishing_components/components/single-page-notification-button
//= require govuk_publishing_components/components/step-by-step-nav

Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/es6-components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= require govuk_publishing_components/components/accordion
//= 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 @@ -53,6 +53,7 @@
<% end %>

<%= stylesheet_link_tag "application", :media => "all", integrity: false %>
<%= javascript_include_tag 'es6-components', type: "module" %>
<%= javascript_include_tag "application", integrity: false %>
<%= csrf_meta_tags %>
<%= render 'govuk_publishing_components/components/meta_tags', content_item: @content_item.content_item %>
Expand Down

0 comments on commit a193195

Please sign in to comment.