Performance: Preload für Haupt-Script mit fetchpriority=high
- Entry-Script wird mit hoher Priorität vorgeladen - Schnellerer JavaScript-Download und Ausführung 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,13 @@ function asyncCssPlugin(): Plugin {
|
|||||||
html = html.replace(/<link rel="modulepreload" crossorigin href="\/assets\/js\/animations[^"]*\.js">\n?/g, '');
|
html = html.replace(/<link rel="modulepreload" crossorigin href="\/assets\/js\/animations[^"]*\.js">\n?/g, '');
|
||||||
html = html.replace(/<link rel="modulepreload" crossorigin href="\/assets\/js\/icons[^"]*\.js">\n?/g, '');
|
html = html.replace(/<link rel="modulepreload" crossorigin href="\/assets\/js\/icons[^"]*\.js">\n?/g, '');
|
||||||
|
|
||||||
|
// Add high priority preload for entry script
|
||||||
|
const mainScriptMatch = html.match(/<script type="module" crossorigin src="(\/assets\/js\/index-[^"]+\.js)">/);
|
||||||
|
if (mainScriptMatch) {
|
||||||
|
const preloadScript = `<link rel="preload" href="${mainScriptMatch[1]}" as="script" crossorigin fetchpriority="high">\n`;
|
||||||
|
html = html.replace('</title>', '</title>\n ' + preloadScript);
|
||||||
|
}
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user