Skip to content

Commit

Permalink
Update website to use <script type="module">
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jul 20, 2023
1 parent 01e4589 commit 4f2b0b0
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/styles/page-template/block-areas/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ stylesheets:
<span class="app-annotate-block__label">block: bodyEnd</span>
{{ super() }}
{# Since we’re not extending the Design System layout we need to add this manually #}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
</div>
{%- endblock %}
4 changes: 2 additions & 2 deletions src/styles/page-template/custom/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,6 @@ ignoreInSitemap: true
{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
{% endblock %}
4 changes: 2 additions & 2 deletions src/styles/page-template/default/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ layout: false
{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
{% endblock %}
4 changes: 2 additions & 2 deletions views/layouts/_generic.njk
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
{% block footer %}{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/application.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application.js') }}"></script>
{% endblock %}
6 changes: 3 additions & 3 deletions views/layouts/layout-example-full-page-govuk.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
{{ contents | safe }}
{% endblock %}
{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/example.js') }}"></script>
<script src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
{% endblock %}
6 changes: 3 additions & 3 deletions views/layouts/layout-example-full-page.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{{ contents | safe }}
{% endblock %}
{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/example.js') }}"></script>
<script src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
{% endblock %}
6 changes: 3 additions & 3 deletions views/layouts/layout-example.njk
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script src="{{ getFingerprint('javascripts/example.js') }}"></script>
<script src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/govuk-frontend.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/vendor/iframeResizer.contentWindow.min.js') }}"></script>
{% endblock %}

{# Example pages shouldn't have a footer, so blank the one provided by the template #}
Expand Down
36 changes: 21 additions & 15 deletions views/partials/_cookie-banner.njk
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,31 @@
to avoid a high cumulative layout shift (CLS) score https://web.dev/cls/ #}
<script>
/* If cookie policy changes and/or the user preferences object format needs to
* change, bump this version up afterwards. The user should then be shown the
* banner again to consent to the new policy.
*
* Note that because isValidCookieConsent checks that the version in the user's
* cookie is equal to or greater than this number, you should be careful to
* check backwards compatibility when changing the object format.
*
/**
* If cookie policy changes and/or the user preferences object format needs to
* change, bump this version up afterwards. The user should then be shown the
* banner again to consent to the new policy.
*
* Note that because isValidCookieConsent checks that the version in the user's
* cookie is equal to or greater than this number, you should be careful to
* check backwards compatibility when changing the object format.
*/
window.GDS_CONSENT_COOKIE_VERSION = 1;
(function () {
/** Check the cookie preferences object.
*
* If the consent object is not present, malformed, or incorrect version,
* returns false, otherwise returns true.
*
* This is also duplicated in cookie-functions.js - the two need to be kept in sync
*/
// Skip early setup when cookie banner component is not supported
if (!('noModule' in HTMLScriptElement.prototype)) {
return
}
/**
* Check the cookie preferences object.
*
* If the consent object is not present, malformed, or incorrect version,
* returns false, otherwise returns true.
*
* This is also duplicated in cookie-functions.js - the two need to be kept in sync
*/
function isValidConsentCookie (options) {
return (options && options.version >= window.GDS_CONSENT_COOKIE_VERSION)
}
Expand Down

0 comments on commit 4f2b0b0

Please sign in to comment.