From 2b6471975803e97b62c5daceedb47b2efe825406 Mon Sep 17 00:00:00 2001 From: sebseb7 Date: Sun, 20 Jul 2025 15:19:16 +0200 Subject: [PATCH] feat: optimize image loading and critical rendering path by adding image preloads in webpack config, updating image handling in multiple components, and ensuring alt attributes are set for accessibility --- src/components/Content.js | 48 +++++++++++++++++++++++++------- src/components/Images.js | 5 ++++ src/components/MainPageLayout.js | 22 ++++++++++++--- src/components/ProductImage.js | 1 + webpack.config.js | 20 ++++++++++++- 5 files changed, 81 insertions(+), 15 deletions(-) diff --git a/src/components/Content.js b/src/components/Content.js index 5e6f666..3577c97 100644 --- a/src/components/Content.js +++ b/src/components/Content.js @@ -634,12 +634,26 @@ class Content extends Component { + Seeds {/* Overlay text - optional */} + Stecklinge {/* Overlay text - optional */} { sx={{ height: "100%", bgcolor: box.bgcolor, - backgroundImage: `url("${box.image}")`, - backgroundSize: "contain", - backgroundPosition: "center", - backgroundRepeat: "no-repeat", position: "relative", + display: "flex", + alignItems: "center", + justifyContent: "center", }} > + {box.title} \n`; }); + // Add critical image preloads for LCP optimization + const criticalImages = [ + '/assets/images/filiale1.jpg', + '/assets/images/filiale2.jpg', + '/assets/images/seeds.jpg', + '/assets/images/cutlings.jpg', + '/assets/images/presse.jpg', + '/assets/images/purpl.jpg' + ]; + + let imagePreloads = ''; + criticalImages.forEach(imagePath => { + imagePreloads += `\n`; + }); + // Add inlined CSS to head const styleTag = ``; - data.html = data.html.replace('', `${fontPreloads}${styleTag}\n`); + data.html = data.html.replace('', `${fontPreloads}${imagePreloads}${styleTag}\n`); console.log(`✅ Inlined CSS assets: ${cssAssets.join(', ')} (${Math.round(inlinedCss.length / 1024)}KB)`); if (fontUrls.length > 0) { console.log(`✅ Added font preloads: ${fontUrls.length} fonts`); } + if (criticalImages.length > 0) { + console.log(`✅ Added image preloads: ${criticalImages.length} critical images`); + } } cb(null, data);