From 7cb24d4d3cbb2c4718444673ae4b32263040cc8e Mon Sep 17 00:00:00 2001 From: djmaze Date: Thu, 23 Sep 2021 15:30:08 +0200 Subject: [PATCH] Speedup boot --- dev/boot.js | 18 +++++++----------- dev/bootstrap.js | 9 +-------- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/dev/boot.js b/dev/boot.js index 7bb985324b..d8d56a4cf5 100644 --- a/dev/boot.js +++ b/dev/boot.js @@ -49,29 +49,25 @@ let RL_APP_DATA = {}; win.rl = { adminArea: () => admin, settings: { - get: name => null == RL_APP_DATA[name] ? null : RL_APP_DATA[name], + get: name => RL_APP_DATA[name], set: (name, value) => RL_APP_DATA[name] = value, - app: name => { - const APP_SETTINGS = RL_APP_DATA.System || {}; - return null == APP_SETTINGS[name] ? null : APP_SETTINGS[name]; - }, - capa: name => name && Array.isArray(RL_APP_DATA.Capa) && RL_APP_DATA.Capa.includes(name) + app: name => RL_APP_DATA.System[name], + capa: name => name && (RL_APP_DATA.Capa || []).includes(name) }, setWindowTitle: title => doc.title = RL_APP_DATA.Title ? (title ? title + ' - ' : '') + RL_APP_DATA.Title : (title ? '' + title : ''), initData: appData => { + const cb = () => rl.app.bootstart(); RL_APP_DATA = appData; - appData - ? loadScript(appData.StaticLibJsLink) + loadScript(appData.StaticLibJsLink) .then(() => loadScript(appData.StaticAppJsLink)) .then(() => appData.PluginsLink ? loadScript(appData.PluginsLink) : Promise.resolve()) - .then(() => win.__APP_BOOT()) + .then(() => ('loading' !== doc.readyState) ? cb() : doc.addEventListener('DOMContentLoaded', cb)) .catch(e => { showError(e.message); throw e; - }) - : showError(); + }); } }; diff --git a/dev/bootstrap.js b/dev/bootstrap.js index b8abd2fa23..a6ce988d7b 100644 --- a/dev/bootstrap.js +++ b/dev/bootstrap.js @@ -1,4 +1,4 @@ -import { doc, dropdownVisibility, Settings } from 'Common/Globals'; +import { dropdownVisibility, Settings } from 'Common/Globals'; import { i18n } from 'Common/Translator'; import { root } from 'Common/Links'; @@ -111,11 +111,4 @@ export default App => { }); }; - window.__APP_BOOT = () => { - const cb = () => { - window.__APP_BOOT = null; - App.bootstart(); - }; - ('loading' !== doc.readyState) ? cb() : doc.addEventListener('DOMContentLoaded', cb); - }; };