diff --git a/.changeset/serious-trainers-cough.md b/.changeset/serious-trainers-cough.md new file mode 100644 index 0000000000..c34ce1df7a --- /dev/null +++ b/.changeset/serious-trainers-cough.md @@ -0,0 +1,6 @@ +--- +"@commercetools-frontend/mc-html-template": patch +"@commercetools-frontend/mc-scripts": patch +--- + +Use `defer` when loading main application JavaScript chunks. diff --git a/packages/mc-html-template/html-docs/application.html b/packages/mc-html-template/html-docs/application.html index 139c8da5b2..1ec683336e 100644 --- a/packages/mc-html-template/html-docs/application.html +++ b/packages/mc-html-template/html-docs/application.html @@ -55,6 +55,9 @@ href="__CDN_URL__favicon_144x144px.png" /> + + __APPLICATION_SCRIPT_IMPORTS__ + __APPLICATION_ENVIRONMENT__ - - - __APPLICATION_SCRIPT_IMPORTS__ diff --git a/packages/mc-html-template/src/webpack-html-template.ts b/packages/mc-html-template/src/webpack-html-template.ts index 3eabcf7d29..cf46cb2016 100644 --- a/packages/mc-html-template/src/webpack-html-template.ts +++ b/packages/mc-html-template/src/webpack-html-template.ts @@ -30,7 +30,7 @@ function webpackHtmlTemplate(templateParams: TemplateParameter) { `` ); const scriptImports = scriptChunks.map( - (chunkPath) => `` + (chunkPath) => `` ); return generateTemplate({ cssImports, scriptImports }); diff --git a/packages/mc-scripts/src/commands/build-vite.ts b/packages/mc-scripts/src/commands/build-vite.ts index 7f696233bd..77822ded9b 100644 --- a/packages/mc-scripts/src/commands/build-vite.ts +++ b/packages/mc-scripts/src/commands/build-vite.ts @@ -21,7 +21,9 @@ async function run() { const html = generateTemplate({ // Define the module entry point (path relative from the `/public` folder). // NOTE: that this is different from the development configuration. - scriptImports: [``], + scriptImports: [ + ``, + ], }); // Write `index.html` (template) into the `/public` folder. fs.writeFileSync(paths.appIndexHtml, html, { encoding: 'utf8' }); diff --git a/packages/mc-scripts/src/commands/start-vite.ts b/packages/mc-scripts/src/commands/start-vite.ts index 0035c9a1c0..53774b6c9d 100644 --- a/packages/mc-scripts/src/commands/start-vite.ts +++ b/packages/mc-scripts/src/commands/start-vite.ts @@ -25,7 +25,7 @@ async function run() { // Define the module entry point (path relative to the `/public` folder). // NOTE: that this is different from the production configuration. scriptImports: [ - ``, + ``, ], }); // Write `index.html` (template) into the `/public` folder.