Commit b9a2a581 authored by Denys Mishunov's avatar Denys Mishunov

Load helpers async after Vue application

This reduces the number of the blocking JS resources on page
load
parent 91fa8e8b
import initNotes from '~/init_notes';
import loadAwardsHandler from '~/awards_handler';
if (!gon.features.snippetsVue) {
const LineHighlighterModule = import('~/line_highlighter');
const BlobViewerModule = import('~/blob/viewer');
const ZenModeModule = import('~/zen_mode');
const SnippetEmbedModule = import('~/snippet/snippet_embed');
const initNotesModule = import('~/init_notes');
const loadAwardsHandlerModule = import('~/awards_handler');
Promise.all([LineHighlighterModule, BlobViewerModule, ZenModeModule, SnippetEmbedModule])
Promise.all([
LineHighlighterModule,
BlobViewerModule,
ZenModeModule,
SnippetEmbedModule,
initNotesModule,
loadAwardsHandlerModule,
])
.then(
([
{ default: LineHighlighter },
{ default: BlobViewer },
{ default: ZenMode },
{ default: SnippetEmbed },
{ default: initNotes },
{ default: loadAwardsHandler },
]) => {
new LineHighlighter(); // eslint-disable-line no-new
new BlobViewer(); // eslint-disable-line no-new
new ZenMode(); // eslint-disable-line no-new
SnippetEmbed();
initNotes();
loadAwardsHandler();
},
)
.catch(() => {});
......@@ -27,7 +37,12 @@ if (!gon.features.snippetsVue) {
.then(({ SnippetShowInit }) => {
SnippetShowInit();
})
.then(() => {
return Promise.all([import('~/init_notes'), import('~/awards_handler')]);
})
.then(([{ default: initNotes }, { default: loadAwardsHandler }]) => {
initNotes();
loadAwardsHandler();
})
.catch(() => {});
}
initNotes();
loadAwardsHandler();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment