refactor: streamline image preloading logic in webpack config by defining critical images outside of conditional checks and improving preload count logging
This commit is contained in:
@@ -174,17 +174,18 @@ class InlineCssPlugin {
|
||||
htmlContent.includes('/admin') || htmlContent.includes('/404') ||
|
||||
htmlContent.includes('/widerrufsrecht') || htmlContent.includes('/batteriegesetzhinweise');
|
||||
|
||||
// Define critical images array
|
||||
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'
|
||||
];
|
||||
|
||||
// Only preload navigation images for main pages (home, categories, aktionen, filiale)
|
||||
if (!isProductPage && !isSpecialPage) {
|
||||
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'
|
||||
];
|
||||
|
||||
criticalImages.forEach(imagePath => {
|
||||
imagePreloads += `<link rel="preload" href="${imagePath}" as="image">\n`;
|
||||
});
|
||||
@@ -198,8 +199,9 @@ class InlineCssPlugin {
|
||||
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`);
|
||||
if (imagePreloads.length > 0) {
|
||||
const preloadCount = (imagePreloads.match(/<link/g) || []).length;
|
||||
console.log(`✅ Added image preloads: ${preloadCount} critical images`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user