From ff92b58e839b7fe2f2fc88b8160e5aa8c5a27f8f Mon Sep 17 00:00:00 2001 From: Damjan Savic Date: Mon, 5 Jan 2026 23:16:35 +0100 Subject: [PATCH] Performance: CSS async laden, kritisches CSS inline erweitert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Vite Plugin für async CSS Loading (preload/onload Trick) - Erweiterte kritische CSS Styles inline - Eliminiert render-blocking CSS (~150ms Einsparung) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .claude/settings.local.json | 8 +++- index.html | 85 +++++++++++++------------------------ vite.config.ts | 19 ++++++++- 3 files changed, 54 insertions(+), 58 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 8e600cd..b7be833 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -33,7 +33,13 @@ "Bash(mv:*)", "Bash(git restore:*)", "Bash(git remote:*)", - "Bash(npx sharp-cli:*)" + "Bash(npx sharp-cli:*)", + "WebFetch(domain:www.googleapis.com)", + "Bash(pip --version:*)", + "Bash(pip install:*)", + "Bash(python:*)", + "Bash(pyftsubset:*)", + "Bash(NODE_TLS_REJECT_UNAUTHORIZED=0 node:*)" ], "deny": [] } diff --git a/index.html b/index.html index eb0f1fb..134d85a 100644 --- a/index.html +++ b/index.html @@ -59,63 +59,36 @@ - + diff --git a/vite.config.ts b/vite.config.ts index 5ec6157..15dc5f8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,10 +1,26 @@ -import { defineConfig } from 'vite'; +import { defineConfig, Plugin } from 'vite'; import react from '@vitejs/plugin-react'; import { VitePWA } from 'vite-plugin-pwa'; import mdx from '@mdx-js/rollup'; import remarkFrontmatter from 'remark-frontmatter'; import remarkMdxFrontmatter from 'remark-mdx-frontmatter'; +// Plugin to make CSS non-blocking using the print media trick +function asyncCssPlugin(): Plugin { + return { + name: 'async-css', + enforce: 'post', + transformIndexHtml(html) { + // Convert blocking CSS to async loading with print media trick + return html.replace( + //g, + ` +` + ); + } + }; +} + export default defineConfig({ plugins: [ { @@ -25,6 +41,7 @@ export default defineConfig({ configFile: false, } }), + asyncCssPlugin(), VitePWA({ strategies: 'generateSW', registerType: 'autoUpdate',