Skip to content

Commit

Permalink
fix: script in pre-render html should be defer or async (#11469)
Browse files Browse the repository at this point in the history
* fix: script in pre-render html should be defer or async

* fix: modify external scripts with async

* fix: modify external scripts with async

* chore: code optimization
  • Loading branch information
MadCcc authored Aug 2, 2023
1 parent 710db4a commit 227ac26
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/preset-umi/src/features/exportStatic/exportStatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ export default (api: IApi) => {

for (const { file, route, prerender } of htmlData) {
let { markupArgs } = opts;
if (api.config.ssr && prerender) {
markupArgs.scripts.forEach((script: any) => {
if (script.src) {
script.async = true;
}
});
}

// handle relative publicPath, such as `./`
if (publicPath.startsWith('.')) {
Expand Down

0 comments on commit 227ac26

Please sign in to comment.