From d7fe7ae39cae03c1c073897f92c92d5f33e1b95a Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 21 Jun 2022 07:02:58 +0530 Subject: [PATCH 1/3] perf(UX): Load splash screen immediately after login --- frappe/templates/includes/login/login.js | 1 + frappe/templates/includes/splash_screen.html | 4 ++++ frappe/www/app.html | 5 +---- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 frappe/templates/includes/splash_screen.html diff --git a/frappe/templates/includes/login/login.js b/frappe/templates/includes/login/login.js index 3af48b4b53..8365947e6c 100644 --- a/frappe/templates/includes/login/login.js +++ b/frappe/templates/includes/login/login.js @@ -195,6 +195,7 @@ login.login_handlers = (function () { 200: function (data) { if (data.message == 'Logged In') { login.set_status('{{ _("Success") }}', 'green'); + document.body.innerHTML = `{% include "templates/includes/splash_screen.html" %}`; window.location.href = frappe.utils.sanitise_redirect(frappe.utils.get_url_arg("redirect-to")) || data.home_page; } else if (data.message == 'Password Reset') { window.location.href = frappe.utils.sanitise_redirect(data.redirect_to); diff --git a/frappe/templates/includes/splash_screen.html b/frappe/templates/includes/splash_screen.html new file mode 100644 index 0000000000..0cbd118dcd --- /dev/null +++ b/frappe/templates/includes/splash_screen.html @@ -0,0 +1,4 @@ +
+ +
\ No newline at end of file diff --git a/frappe/www/app.html b/frappe/www/app.html index 4402dbb481..f4de074d32 100644 --- a/frappe/www/app.html +++ b/frappe/www/app.html @@ -26,10 +26,7 @@ {% include "public/icons/timeless/symbol-defs.svg" %} -
- -
+ {% include "templates/includes/splash_screen.html" %}
From d6f2d34bf4b9e214c8dff273ba05302766ff9a10 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Sat, 18 Jun 2022 22:20:49 +0530 Subject: [PATCH 2/3] perf: send boot string instead of JSON literal changes: - compact boot info in /app HTML /app size went from 451kb to 393kb - ~13% less Verified that regex applied on this JSON aren't affecting perf, infact found them to be faster with compact JSON. - Send json string instead of placing JSON literal in code using Jinja. JS takes more time to pass object literal than parsing a plain JSON string. Overall content transfer size remains roughly same (albeit slightly lower) since double escaping ends up adding extra `\` around quotes. Co-authored-by: Suraj Shetty --- frappe/www/app.html | 2 +- frappe/www/app.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/frappe/www/app.html b/frappe/www/app.html index f4de074d32..9189570674 100644 --- a/frappe/www/app.html +++ b/frappe/www/app.html @@ -42,7 +42,7 @@ if (!window.frappe) window.frappe = {}; - frappe.boot = {{ boot }}; + frappe.boot = JSON.parse({{ boot }}); frappe._messages = frappe.boot["__messages"]; frappe.csrf_token = "{{ csrf_token }}"; diff --git a/frappe/www/app.py b/frappe/www/app.py index 9a8c80d6b1..0447d00f89 100644 --- a/frappe/www/app.py +++ b/frappe/www/app.py @@ -2,6 +2,7 @@ # License: MIT. See LICENSE no_cache = 1 +import json import os import re @@ -32,13 +33,14 @@ def get_context(context): frappe.db.commit() - boot_json = frappe.as_json(boot) + boot_json = frappe.as_json(boot, indent=None, separators=(",", ":")) # remove script tags from boot boot_json = SCRIPT_TAG_PATTERN.sub("", boot_json) # TODO: Find better fix boot_json = CLOSING_SCRIPT_TAG_PATTERN.sub("", boot_json) + boot_json = json.dumps(boot_json) context.update( { From 9f2dfbe98030f1d19e1d8ee2d0e18453081e8487 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Tue, 21 Jun 2022 09:06:34 +0530 Subject: [PATCH 3/3] chore: Fix merge error --- frappe/www/app.html | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frappe/www/app.html b/frappe/www/app.html index a6db88604f..204b7d841e 100644 --- a/frappe/www/app.html +++ b/frappe/www/app.html @@ -27,10 +27,6 @@ {% include "public/icons/timeless/icons.svg" %} {% include "templates/includes/splash_screen.html" %} -
- -