From 7ef0c5d4f91b83632b2a102647ffcf266f5a1239 Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Wed, 29 Sep 2021 18:19:52 -0700 Subject: [PATCH] ref(js): Improve app boot ordering We don't actually need to wait on initializeMain until after we've completed bootstrapping, which can be done in parallel. --- static/app/index.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/static/app/index.tsx b/static/app/index.tsx index edab70a6edd6a4..ed80b621740391 100644 --- a/static/app/index.tsx +++ b/static/app/index.tsx @@ -66,12 +66,16 @@ // details for the org, projects, and teams. async function app() { - const [{bootstrap}, {initializeMain}] = await Promise.all([ - import('app/bootstrap'), - import('app/bootstrap/initializeMain'), - ]); - const data = await bootstrap(); - initializeMain(data); + // We won't need initalizeMainImport until we complete bootstrapping. + // Initaite the fetch, just don't await it until we need it. + const initalizeMainImport = import('app/bootstrap/initializeMain'); + const bootstrapImport = import('app/bootstrap'); + + const {bootstrap} = await bootstrapImport; + const config = await bootstrap(); + + const {initializeMain} = await initalizeMainImport; + initializeMain(config); } app();