Effort 2 is the step worth taking for WebP in sharp. On a 1920 × 1076 photo at quality 80, effort 0 wrote 130.9 KB in 34 ms. Effort 2 wrote 110.4 KB in 60 ms, which is 15.6% smaller for 26 ms more. Effort 6 wrote 102.3 KB but took 214 ms. The default, effort 4, sits in the middle at 106.9 KB and 141 ms.
Here is the script, what it printed, and how the curve changes for screenshots and lossless files.
What does effort do in sharp's webp()?
The effort option is CPU effort, from 0 (fastest) to 6 (slowest), with a default of 4. The sharp output docs say that and little more. In plain terms, it sets how many encoding tools the encoder tries before it settles.
Effort does not change quality. At a fixed quality, a higher effort should give a smaller file of about the same picture. The next sections test that claim.
How do you time WebP effort levels?
Decode and resize once, keep the raw pixels, then time only the encode. If you time the whole pipeline, the JPEG decode hides the low levels.
// webp-effort.mjs: node webp-effort.mjs photo.jpeg 1920
import sharp from 'sharp';
const { data, info } = await sharp(process.argv[2]).rotate()
.resize({ width: Number(process.argv[3] || 1920) }).removeAlpha()
.raw().toBuffer({ resolveWithObject: true });
const raw = { raw: { width: info.width, height: info.height, channels: 3 } };
const median = (a) => [...a].sort((x, y) => x - y)[Math.floor(a.length / 2)];
for (let effort = 0; effort <= 6; effort++) {
const times = [];
let bytes = 0;
for (let run = 0; run < 5; run++) {
const t0 = performance.now();
const out = await sharp(data, raw).webp({ quality: 80, effort }).toBuffer();
times.push(performance.now() - t0);
bytes = out.length;
}
console.log(`effort ${effort} ${(bytes / 1000).toFixed(1)} KB ${Math.round(median(times))} ms`);
}
I ran it on our 4964 × 2782 camera photo (a lake at sunset with a boat), resized to 1920 pixels wide, and added a PSNR column against the resized pixels:
effort 0 130.9 KB 34 ms PSNR 38.54
effort 1 121.8 KB 42 ms PSNR 38.56
effort 2 110.4 KB 60 ms PSNR 38.49
effort 3 106.6 KB 139 ms PSNR 38.68
effort 4 106.9 KB 141 ms PSNR 38.69
effort 5 104.7 KB 153 ms PSNR 38.57
effort 6 102.3 KB 214 ms PSNR 38.47
Where does the extra time buy bytes?
Most of the saving comes early. Time jumps in the middle.
- Effort 0 to 2: 20.5 KB saved (15.6%) for 26 ms more.
- Effort 2 to 3: 3.8 KB saved (3.4%), but the time more than doubled, 60 ms to 139 ms.
- Effort 3 to 4: no gain. Effort 3 wrote 106,636 bytes and effort 4 wrote 106,876 bytes.
- Effort 4 to 6: 4.6 KB saved (4.3%) for 73 ms more.
Effort 3 and 4 are the same speed and the same size on this photo. The default is not wrong, but it buys nothing over 3 here.
Does a higher effort change quality?
Not in any way you would notice. PSNR stays between 38.47 dB and 38.69 dB for all seven levels, and it does not rise with effort. Effort 6 scored 38.47 dB, the lowest of the set, while writing the smallest file.
So the levels trade time for bytes at one visual quality. That is the useful way to read the chart.
Note: PSNR is a rough measure and I ran it once per setting. A spread of 0.2 dB is noise at this size. Do not pick a level because it scored 38.69 over 38.47.
What about screenshots and lossless WebP?
The curve has the same shape for a flat UI screenshot, and it is steeper. I used our pricing page screenshot, 2880 × 1800 resized to 1440 × 900, at quality 80:
effort 0 60.2 KB 20 ms PSNR 42.48
effort 1 57.2 KB 23 ms PSNR 42.51
effort 2 47.0 KB 54 ms PSNR 42.06
effort 3 45.9 KB 67 ms PSNR 42.24
effort 4 45.9 KB 70 ms PSNR 42.25
effort 5 45.7 KB 97 ms PSNR 41.88
effort 6 44.8 KB 102 ms PSNR 42.01
Effort 0 to 6 saved 25.5% here, against 21.9% on the photo. Effort 2 already took 47.0 KB, within 4.9% of effort 6.
Lossless is where effort misleads. With lossless: true on the same screenshot:
effort 0 424.2 KB 125 ms
effort 1 330.1 KB 547 ms
effort 2 323.2 KB 703 ms
effort 3 323.2 KB 655 ms
effort 4 323.2 KB 679 ms
effort 5 324.1 KB 1014 ms
effort 6 339.3 KB 896 ms
Effort 2, 3 and 4 wrote the same 323,152 bytes. Effort 6 wrote 339.3 KB, 5.0% larger than effort 4, and took longer. On this file, a higher effort made the lossless output worse.
For the lossless photo (1920 × 1076, median of 3 runs), effort 0 wrote 2,276.6 KB in 683 ms and effort 6 wrote 2,002.4 KB in 2,820 ms. Lossless photos are big whatever you pick.
Which effort level should you use?
- Uploads and queue jobs: effort 2 or 3. You keep most of the saving and stay near 60 to 140 ms for a 1920 pixel photo.
- A build step that runs once per image: effort 5 or 6. The extra 70 ms happens once and every visitor gets the smaller file.
- Lossless WebP: effort 2 to 4. Test 5 and 6 on your own files before you trust them, since 6 lost on my screenshot.
- Skip: effort 0 and 1 for anything a person will download. Effort 0 cost 18.5% more bytes than effort 2, and effort 1 cost 10.3% more.
How WebP compares with AVIF and JPEG on a photo is a separate question from effort. This article only covers the effort dial inside WebP.
How I measured
- Photo:
apps/web/public/images/index/image-compressor-sample-camera-photo.jpeg, 4964 × 2782, resized to 1920 × 1076 with sharp's default kernel. - Screenshot: our pricing page,
apps/web/assets/reference/screenshot.png, 2880 × 1800, resized to 1440 × 900. - Versions: Node 24.22.0, sharp 0.35.4, libvips 8.18.6, libwebp 1.6.0.
- Time: encode only from raw pixels, median of 5 runs (3 for the lossless photo),
performance.now(). - PSNR: RGB, against the resized raw pixels, one run per setting.
- Machine: Apple M1 Pro, macOS, 2026-10-18. The full harness is
apps/web/scripts/devto-images/_measure-sharp-tuning.mjs, and the table blocks above are itsmeasured.jsonoutput, reformatted.
What I did not test
One photo and one screenshot are not every image. I did not test alphaQuality, animated WebP, smartSubsample, or Linux servers, where timing can differ.
I build Blinkimg, an image compressor and converter with a developer API. I wrote this article with help from an AI assistant (Claude), which ran the code on my machine; every number in it comes from those runs.

Top comments (0)