From 4575ad0fcdce3efce3f51a21809566d13fbdaf8a Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Tue, 18 May 2021 12:38:05 +0100 Subject: [PATCH] Only check for WebAuthn where it's used This scopes the check for WebAuthn API to the page where we need it, which will slightly reduce load times for other pages. Since we want this script to execute ASAP, I've added a new block for extra JS to run at the start of the body. --- app/templates/admin_template.html | 4 +--- app/templates/views/user-profile/security-keys.html | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html index 814ea7c54..55f3a96d3 100644 --- a/app/templates/admin_template.html +++ b/app/templates/admin_template.html @@ -1,7 +1,6 @@ {% extends "template.njk" %} {% from "components/banner.html" import banner %} {% from "components/cookie-banner.html" import cookie_banner %} -{% from "components/webauthn-api-check.html" import webauthn_api_check %} {% block headIcons %} @@ -39,8 +38,7 @@ {% endblock %} {% block bodyStart %} - {% block webauthn_api %} - {{ webauthn_api_check() }} + {% block extra_javascripts_before_body %} {% endblock %} {% block cookie_message %} diff --git a/app/templates/views/user-profile/security-keys.html b/app/templates/views/user-profile/security-keys.html index b30e79d16..c510ff992 100644 --- a/app/templates/views/user-profile/security-keys.html +++ b/app/templates/views/user-profile/security-keys.html @@ -3,11 +3,16 @@ {% from "components/button/macro.njk" import govukButton %} {% from "components/back-link/macro.njk" import govukBackLink %} {% from "components/table.html" import mapping_table, row, field, row_heading %} +{% from "components/webauthn-api-check.html" import webauthn_api_check %} {% from "vendor/govuk-frontend/components/error-message/macro.njk" import govukErrorMessage %} {% set page_title = 'Security keys' %} {% set credentials = current_user.webauthn_credentials %} +{% block extra_javascripts_before_body %} + {{ webauthn_api_check() }} +{% endblock %} + {% block per_page_title %} {{ page_title }} {% endblock %}