perf: revert InteractiveGermanyMap to dynamic import and use ReactDOM.preload for LCP
This commit is contained in:
@@ -19,7 +19,7 @@ import JsonLd from '@/components/JsonLd';
|
|||||||
import { Button } from '@/components/ui/Button';
|
import { Button } from '@/components/ui/Button';
|
||||||
import { Heading } from '@/components/ui/Heading';
|
import { Heading } from '@/components/ui/Heading';
|
||||||
const AnimatedCounter = nextDynamic(() => import('@/components/ui').then(mod => mod.AnimatedCounter));
|
const AnimatedCounter = nextDynamic(() => import('@/components/ui').then(mod => mod.AnimatedCounter));
|
||||||
import { InteractiveGermanyMap } from '@/components/blocks/InteractiveGermanyMap';
|
const InteractiveGermanyMap = nextDynamic(() => import('@/components/blocks/InteractiveGermanyMap').then(mod => mod.InteractiveGermanyMap));
|
||||||
const ScaleOfImpact = nextDynamic(() => import('@/components/blocks/ScaleOfImpact').then(mod => mod.ScaleOfImpact));
|
const ScaleOfImpact = nextDynamic(() => import('@/components/blocks/ScaleOfImpact').then(mod => mod.ScaleOfImpact));
|
||||||
import { getAllReferences } from '@/lib/references';
|
import { getAllReferences } from '@/lib/references';
|
||||||
|
|
||||||
@@ -122,7 +122,9 @@ export async function generateMetadata(props: any): Promise<Metadata> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Home(props: any) {
|
import { preload } from 'react-dom';
|
||||||
|
|
||||||
|
export default async function Home(props: { params: Promise<{ locale: string }> }) {
|
||||||
const { locale } = await props.params;
|
const { locale } = await props.params;
|
||||||
|
|
||||||
if (locale !== 'de' && locale !== 'en') {
|
if (locale !== 'de' && locale !== 'en') {
|
||||||
@@ -130,6 +132,7 @@ export default async function Home(props: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setRequestLocale(locale);
|
setRequestLocale(locale);
|
||||||
|
preload('/germany-map.svg', { as: 'image', fetchPriority: 'high' });
|
||||||
|
|
||||||
const mdx = await getMdxContent(locale, 'home');
|
const mdx = await getMdxContent(locale, 'home');
|
||||||
const allReferences = await getAllReferences(locale);
|
const allReferences = await getAllReferences(locale);
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import { getButtonClasses, ButtonOverlay } from '@/components/ui/Button';
|
|||||||
import { SITE_URL } from '@/lib/schema';
|
import { SITE_URL } from '@/lib/schema';
|
||||||
import Image from 'next/image';
|
import Image from 'next/image';
|
||||||
import { standorteData, standorteLocations } from '@/lib/standorte-data';
|
import { standorteData, standorteLocations } from '@/lib/standorte-data';
|
||||||
import { InteractiveGermanyMap } from '@/components/blocks/InteractiveGermanyMap';
|
import nextDynamic from 'next/dynamic';
|
||||||
|
const InteractiveGermanyMap = nextDynamic(() => import('@/components/blocks/InteractiveGermanyMap').then(mod => mod.InteractiveGermanyMap));
|
||||||
|
|
||||||
interface PageProps {
|
interface PageProps {
|
||||||
params: Promise<{
|
params: Promise<{
|
||||||
@@ -33,11 +34,15 @@ export async function generateMetadata({ params }: { params: Promise<{ locale: s
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { preload } from 'react-dom';
|
||||||
|
|
||||||
export default async function StandorteOverview(props: { params: Promise<{ locale: string }> }) {
|
export default async function StandorteOverview(props: { params: Promise<{ locale: string }> }) {
|
||||||
const { locale } = await props.params;
|
const { locale } = await props.params;
|
||||||
const safeLocale = locale === 'de' ? 'de' : 'en';
|
const safeLocale = locale === 'de' ? 'de' : 'en';
|
||||||
setRequestLocale(safeLocale);
|
setRequestLocale(safeLocale);
|
||||||
const t = await getTranslations('StandardPage');
|
const t = await getTranslations('StandardPage');
|
||||||
|
|
||||||
|
preload('/germany-map.svg', { as: 'image', fetchPriority: 'high' });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col min-h-screen bg-neutral-50 pb-16 md:pb-24">
|
<div className="flex flex-col min-h-screen bg-neutral-50 pb-16 md:pb-24">
|
||||||
|
|||||||
11921
lh-desktop.json
Normal file
11921
lh-desktop.json
Normal file
File diff suppressed because one or more lines are too long
11867
lh-report.json
Normal file
11867
lh-report.json
Normal file
File diff suppressed because one or more lines are too long
36
run-lh.cjs
Normal file
36
run-lh.cjs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
console.log("Running Lighthouse...");
|
||||||
|
try {
|
||||||
|
execSync('npx lighthouse "https://e-tib.com/de/standorte?v=2" --chrome-flags="--headless --no-sandbox" --output json --output-path ./lh-report.json', { stdio: 'inherit' });
|
||||||
|
} catch(e) {
|
||||||
|
console.log("Lighthouse run failed", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = JSON.parse(fs.readFileSync('./lh-report.json', 'utf8'));
|
||||||
|
const score = data.categories.performance.score * 100;
|
||||||
|
console.log("\n==================================");
|
||||||
|
console.log(`PERFORMANCE SCORE: ${score}`);
|
||||||
|
console.log("==================================\n");
|
||||||
|
|
||||||
|
console.log("FAILING METRICS (Score < 1.0):");
|
||||||
|
Object.values(data.audits).filter(a => a.score !== null && a.score < 1).forEach(a => {
|
||||||
|
console.log(`- ${a.id}: ${a.score} (${a.displayValue || 'No display value'})`);
|
||||||
|
if (a.details && a.details.items && a.details.items.length > 0) {
|
||||||
|
if (a.id === 'image-delivery-insight' || a.id === 'unused-javascript' || a.id === 'modern-image-formats' || a.id === 'uses-responsive-images') {
|
||||||
|
console.log(" Items:");
|
||||||
|
a.details.items.forEach(item => {
|
||||||
|
console.log(` URL: ${item.url || item.node?.nodeLabel || 'unknown'}`);
|
||||||
|
if (item.wastedBytes) console.log(` Wasted KB: ${(item.wastedBytes / 1024).toFixed(2)}`);
|
||||||
|
if (item.wastedMs) console.log(` Wasted Ms: ${item.wastedMs}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("\nLCP BREAKDOWN:");
|
||||||
|
const lcpElement = data.audits['largest-contentful-paint-element'];
|
||||||
|
if (lcpElement && lcpElement.details && lcpElement.details.items) {
|
||||||
|
console.log("LCP Element:", lcpElement.details.items[0].node.snippet);
|
||||||
|
}
|
||||||
36
run-lh.js
Normal file
36
run-lh.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
console.log("Running Lighthouse...");
|
||||||
|
try {
|
||||||
|
execSync('npx lighthouse "https://e-tib.com/de/standorte?v=2" --chrome-flags="--headless --no-sandbox" --output json --output-path ./lh-report.json', { stdio: 'inherit' });
|
||||||
|
} catch(e) {
|
||||||
|
console.log("Lighthouse run failed", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = JSON.parse(fs.readFileSync('./lh-report.json', 'utf8'));
|
||||||
|
const score = data.categories.performance.score * 100;
|
||||||
|
console.log("\n==================================");
|
||||||
|
console.log(`PERFORMANCE SCORE: ${score}`);
|
||||||
|
console.log("==================================\n");
|
||||||
|
|
||||||
|
console.log("FAILING METRICS (Score < 1.0):");
|
||||||
|
Object.values(data.audits).filter(a => a.score !== null && a.score < 1).forEach(a => {
|
||||||
|
console.log(`- ${a.id}: ${a.score} (${a.displayValue || 'No display value'})`);
|
||||||
|
if (a.details && a.details.items && a.details.items.length > 0) {
|
||||||
|
if (a.id === 'image-delivery-insight' || a.id === 'unused-javascript' || a.id === 'modern-image-formats' || a.id === 'uses-responsive-images') {
|
||||||
|
console.log(" Items:");
|
||||||
|
a.details.items.forEach(item => {
|
||||||
|
console.log(` URL: ${item.url || item.node?.nodeLabel || 'unknown'}`);
|
||||||
|
if (item.wastedBytes) console.log(` Wasted KB: ${item.wastedBytes / 1024}`);
|
||||||
|
if (item.wastedMs) console.log(` Wasted Ms: ${item.wastedMs}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("\nLCP BREAKDOWN:");
|
||||||
|
const lcpElement = data.audits['largest-contentful-paint-element'];
|
||||||
|
if (lcpElement && lcpElement.details && lcpElement.details.items) {
|
||||||
|
console.log("LCP Element:", lcpElement.details.items[0].node.snippet);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user