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 Dec 4, 2023
1 parent d9c2c8c commit c3f30d6
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/styles/page-template/block-areas/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ 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/application-example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
</div>
{%- endblock %}
2 changes: 1 addition & 1 deletion src/styles/page-template/custom/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,5 @@ ignoreInSitemap: true
{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion src/styles/page-template/default/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ layout: false
{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion views/layouts/_generic.njk
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
{% block footer %}{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/application.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion views/layouts/layout-example-full-page-govuk.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
{{ contents | safe }}
{% endblock %}
{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion views/layouts/layout-example-full-page.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
{{ contents | safe }}
{% endblock %}
{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion views/layouts/layout-example.njk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{% endblock %}

{% block bodyEnd %}
<script src="{{ getFingerprint('javascripts/application-example.js') }}"></script>
<script type="module" src="{{ getFingerprint('javascripts/application-example.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 @@ -74,25 +74,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 c3f30d6

Please sign in to comment.