From acda0e8883410bc4012a7b0eb75e10f36752f860 Mon Sep 17 00:00:00 2001 From: djmaze Date: Thu, 10 Sep 2020 10:07:35 +0200 Subject: [PATCH] Speedup boot.js: no need to load CKEditor/Squire when not logged in --- dev/boot.js | 33 ++++++++++++++++----------------- dev/bootstrap.js | 2 +- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/dev/boot.js b/dev/boot.js index 75373910d..19c827b02 100644 --- a/dev/boot.js +++ b/dev/boot.js @@ -156,6 +156,14 @@ win.__initAppData = appData => { } appData.IncludeCss && writeCSS(appData.IncludeCss); + + if (appData.IncludeBackground) { + const img = appData.IncludeBackground.replace('{{USER}}', rl.hash.get() || '0'); + if (img) { + html.classList.add('UserBackground'); + doc.body.style.backgroundImage = "url("+img+")"; + } + } } if ( @@ -163,23 +171,11 @@ win.__initAppData = appData => { appData.TemplatesLink && appData.LangLink && appData.StaticLibJsLink && - appData.StaticAppJsLink && - appData.StaticEditorJsLink + appData.StaticAppJsLink ) { p.set(5); - const libs = () => - loadScript(appData.StaticLibJsLink).then(() => { - if (appData.IncludeBackground) { - const img = appData.IncludeBackground.replace('{{USER}}', rl.hash.get() || '0'); - if (img) { - html.classList.add('UserBackground'); - doc.body.style.backgroundImage = "url("+img+")"; - } - } - }); - - libs() + loadScript(appData.StaticLibJsLink) .then(() => { p.set(20); return Promise.all([loadScript(appData.TemplatesLink), loadScript(appData.LangLink)]); @@ -200,10 +196,13 @@ win.__initAppData = appData => { runMainBoot(true); throw e; }) - .then(() => loadScript(appData.StaticEditorJsLink)) .then(() => { - win.__initEditor && win.__initEditor(); - win.__initEditor = null; + if (appData.Auth) { + loadScript(appData.StaticEditorJsLink).then(() => { + win.__initEditor && win.__initEditor(); + win.__initEditor = null; + }); + } }); } else { runMainBoot(true); diff --git a/dev/bootstrap.js b/dev/bootstrap.js index 2b23f75c0..6521aef91 100644 --- a/dev/bootstrap.js +++ b/dev/bootstrap.js @@ -1,4 +1,4 @@ -import { data as GlobalsData, bMobileDevice, dropdownVisibility } from 'Common/Globals'; +import { data as GlobalsData, dropdownVisibility } from 'Common/Globals'; import * as Enums from 'Common/Enums'; import * as Plugins from 'Common/Plugins'; import { i18n } from 'Common/Translator';