Skip to content

perf (lazysizes): remove lazysizes, use native lazy attribute instead #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions assets/conf-img/sizes/square-native.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"width": 500,
"height": 500,
"crop": true
},
{
"width": 1000,
"height": 1000,
"crop": true
}
]
5 changes: 5 additions & 0 deletions assets/conf-img/tpl/default-native-caption.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%%data-location%%
<figure>
<img %%src%% %%srcset%% %%attributes%% />
<figcaption>%%caption%%</figcaption>
</figure>
2 changes: 2 additions & 0 deletions assets/conf-img/tpl/default-native.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%%data-location%%
<img %%src%% %%srcset%% %%attributes%% />
266 changes: 0 additions & 266 deletions config/WebpackImageSizesPlugin.js

This file was deleted.

12 changes: 10 additions & 2 deletions config/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const WebpackBar = require('webpackbar')
const DependencyExtractionWebpackPlugin = require('@wordpress/dependency-extraction-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

const WebpackImageSizesPlugin = require('./WebpackImageSizesPlugin')
const WebpackImageSizesPlugin = require('./webpack-image-sizes-plugin')

module.exports = {
get: function (mode) {
Expand All @@ -33,7 +33,15 @@ module.exports = {
}),
new DependencyExtractionWebpackPlugin(),
new WebpackImageSizesPlugin({
watch: mode !== 'production',
confImgPath: 'assets/conf-img', // Path to the conf-img folder
sizesSubdir: 'sizes', // Subdirectory containing the sizes JSON files
tplSubdir: 'tpl', // Subdirectory containing TPL templates
outputImageLocations: 'image-locations.json', // Output locations file name
outputImageSizes: 'image-sizes.json', // Output sizes file name
generateDefaultImages: true, // Generate default images
defaultImageSource: 'src/img/static/default.jpg', // Source image for generation
defaultImagesOutputDir: 'dist/images', // Default images output directory
defaultImageFormat: 'jpg', // Generated image format (jpg, png, webp, avif)
}),
]

Expand Down
Loading
Loading