Skip to content
Snippets Groups Projects
Commit 8c90ed1c authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

optimize courseware loading by loading chunk and app in parallel, fixes #3364

Closes #3364

Merge request studip/studip!2286
parent 8d3ddd26
No related branches found
No related tags found
No related merge requests found
STUDIP.domReady(() => { STUDIP.domReady(() => {
if (document.getElementById('courseware-shelf-app')) { if (document.getElementById('courseware-shelf-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-shelf-app" */ /* webpackChunkName: "courseware-shelf-app" */
'@/vue/courseware-shelf-app.js' '@/vue/courseware-shelf-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-shelf-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-shelf-app');
}); });
} }
if (document.getElementById('courseware-index-app')) { if (document.getElementById('courseware-index-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-index-app" */ /* webpackChunkName: "courseware-index-app" */
'@/vue/courseware-index-app.js' '@/vue/courseware-index-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-index-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-index-app');
}); });
} }
if (document.getElementById('courseware-activities-app')) { if (document.getElementById('courseware-activities-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-activities-app" */ /* webpackChunkName: "courseware-activities-app" */
'@/vue/courseware-activities-app.js' '@/vue/courseware-activities-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-activities-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-activities-app');
}); });
} }
if (document.getElementById('courseware-tasks-app')) { if (document.getElementById('courseware-tasks-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-tasks-app" */ /* webpackChunkName: "courseware-tasks-app" */
'@/vue/courseware-tasks-app.js' '@/vue/courseware-tasks-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-tasks-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-tasks-app');
}); });
} }
if (document.getElementById('courseware-content-bookmark-app')) { if (document.getElementById('courseware-content-bookmark-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-content-bookmark-app" */ /* webpackChunkName: "courseware-content-bookmark-app" */
'@/vue/courseware-content-bookmark-app.js' '@/vue/courseware-content-bookmark-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-content-bookmark-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-content-bookmark-app');
}); });
} }
if (document.getElementById('courseware-admin-app')) { if (document.getElementById('courseware-admin-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-content-bookmark-app" */ /* webpackChunkName: "courseware-content-bookmark-app" */
'@/vue/courseware-admin-app.js' '@/vue/courseware-admin-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-admin-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-admin-app');
}); });
} }
if (document.getElementById('courseware-public-app')) { if (document.getElementById('courseware-public-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-public-app" */ /* webpackChunkName: "courseware-public-app" */
'@/vue/courseware-public-app.js' '@/vue/courseware-public-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-public-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-public-app');
}); });
} }
if (document.getElementById('courseware-content-releases-app')) { if (document.getElementById('courseware-content-releases-app')) {
STUDIP.loadChunk('courseware').then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-content-releases-app" */ /* webpackChunkName: "courseware-content-releases-app" */
'@/vue/courseware-content-releases-app.js' '@/vue/courseware-content-releases-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-content-releases-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-content-releases-app');
}); });
} }
if (document.getElementById('courseware-comments-app')) { if (document.getElementById('courseware-comments-app')) {
STUDIP.Vue.load().then(({ createApp }) => { Promise.all([
STUDIP.loadChunk('courseware'),
import( import(
/* webpackChunkName: "courseware-comments-app" */ /* webpackChunkName: "courseware-comments-app" */
'@/vue/courseware-comments-app.js' '@/vue/courseware-comments-app.js'
).then(({ default: mountApp }) => { ),
return mountApp(STUDIP, createApp, '#courseware-comments-app'); ]).then(([{ createApp }, { default: mountApp }]) => {
}); return mountApp(STUDIP, createApp, '#courseware-comments-app');
}); });
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment