Open jeffkaufman opened 8 years ago
@huibaolin Can you think of any reason this would happen?
There are 2 issues in the HTML: http://www.jefftk.com/uva--a-href-image
<img>
is embedded inside <a>
tag.The illustrate, the HTML looks like
<a ... ><img ...></a><custom ...>
Images inside <a>
and <custom>
are not rewritten. They are just cache extended. Only the images inside <img>
have been optimized.
Changing the HTML to the following makes all image optimized:
<a ...></a><img ...><custom ...></custom>
We don't rewrite images in an element (<a>
tag here) if it has any child (<img>
here) which might be in flush window.
@huibaolin Thanks for catching that! It sounds like the problem is that we don't rewrite image attributes of tags that have children? Why not? Can't we rewrite the <a ...
when we get to the >
?
Yes, we don't rewrite attributes (image & css) if a tag has children and the children might be in a different flush window. I think the problem is because we can't propagate up correctly. @morlovich might have more details.
With
UrlValuedAttribute
you can tell pagespeed about other attributes but it won't turn them into webp unless they're on animg
tag:See this demo page: http://www.jefftk.com/uva--a-href-image
Reported on the mailing list: https://groups.google.com/d/msgid/mod-pagespeed-discuss/CAD%2Biv0wXSwQ4MenawEz_3X0f1w5sxzQxLQOAUyw5__YYMucT_w%40mail.gmail.com?utm_medium=email&utm_source=footer