I think that what you did there is functionally correct, but it could be condensed to something like: https://gist.github.com/oschaaf/ce4f332ef64cc85371e38f47992ffadf
Should this new handling of kDataSrcset be default behavior? Or should it be an opt-in feature? Would it be possible to create a pull request with that change? Otto On Thu, Jun 13, 2019 at 8:45 PM Longinos Ferrando <[email protected]> wrote: > Hi to all > As @oschaaf seguested I send this to the dev list. > Digiing in the code I found that in > archive net/instaweb/rewriter/image_rewrite_filter.cc lines 2141 - 2146 > have a if statement to test HtmlName::kImg and a test to check if > HtmlName::kSrcset > is present. > This make that other attributes like data-srcset can“t be > rewrited/optimized by pagespeed. > I make a test, and it is working getting data-srcset optimized. > 1.- Insert kDataSrcset, in pagespeed/kernel/html/html_name.h as line 105 > 2.- Insert "data-srcset", HtmlName::kDataSrcset > in pagespeed/kernel/html/html_name.gperf as line 129 > 3.- Chenged lines 2141-22146 in the file > net/instaweb/rewriter/image_rewrite_filter.cc > lines with > > 2141 if (element->keyword() == HtmlName::kImg) { > HtmlElement::Attribute* srcset = > element->FindAttribute(HtmlName::kSrcset); > HtmlElement::Attribute* datasrcset = > element->FindAttribute(HtmlName::kDataSrcset); > if (srcset != nullptr) { > BeginRewriteSrcSet(element, srcset); > } > if (datasrcset != nullptr) { > srcset = datasrcset ; > BeginRewriteSrcSet(element, srcset); > } > > } > > This work, data-srcset attributes are rewrited/optimized, but for sure is > not the best way to do as far as i not a developer. > > Any thougths? > > Thx in advance >
