Skip to content

Commit

Permalink
let's not destroy source elements
Browse files Browse the repository at this point in the history
  • Loading branch information
georges-gomes committed Apr 19, 2024
1 parent 0fe32ae commit 7c8445b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/optimize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,11 @@ async function processImage(
const picture = img.parent();

if (isAboveTheFold && srcToFormat === 'jpeg+progressive') {
// We don't need anything else than jpeg progressive above the fold
const nodes = picture.children(`source`);
nodes.remove();
// We were previously removing <source> elements here
// but they may be used to express art direction
// + WebP or AVIF may be a lot smaller than JPEG progressive...
// So for the moment we do nothing else
// just add the JPEG progressive
} else {
// List of possible sources to generate
//
Expand Down

0 comments on commit 7c8445b

Please sign in to comment.