Wp-rocket: Incompatibility between ShortPixel Global WebP rewrite and WPR Lazyload

Created on 7 May 2019  ·  5Comments  ·  Source: wp-media/wp-rocket

Shortpixel uses the init hook with a priority of 1 to call its output buffer function to rewrite the default img tag to the picture tag.

Meanwhile, WP Rocket uses the template_redirect with a priority of 2.

This means Shortpixel rewrite happens after WP Rocket rewrite, producing unexpected markup, and breaking lazyload.

Shortpixel also provides a solution based on WP hooks, and this one works well with our own buffering.

2 solutions here:

  • ShortPixel changes the hook they use, to use template_redirect with a priority higher than 2.
  • We add a way to change the default hook and priority we use, to make sure we perform our optimizations after ShortPixel
3rd party compatibility lazyload low moderate bug

Most helpful comment

Just to add (I think this is the issue I've been hit with). For me Shortpixel AI (which adds Webp and a CDN rewrite to all images) just did nothing when WP Rocket Lazyload was enabled.

Shortpixel AI (Adaptive Images) includes Lazy Loading itself. All you have to do is switch the WP Rocket Lazy Load for images option off and Shortpixel AI starts to work. Maybe a 3rd option is to notify and disable WP Rocket lazy load when Shortpixel AI is detected as enabled?

All 5 comments

Note from version doc proposal - "Remy noted that this was a little risky in terms of how it could produce issues, and so far has only produced 2 tickets. So we decided to leave it out of 3.3.4"

Just to add (I think this is the issue I've been hit with). For me Shortpixel AI (which adds Webp and a CDN rewrite to all images) just did nothing when WP Rocket Lazyload was enabled.

Shortpixel AI (Adaptive Images) includes Lazy Loading itself. All you have to do is switch the WP Rocket Lazy Load for images option off and Shortpixel AI starts to work. Maybe a 3rd option is to notify and disable WP Rocket lazy load when Shortpixel AI is detected as enabled?

i would like to suggest that Rocket WP allow the option to serve up WebP with the element when you‘re not using the Caching portion of Rocket WP. I’m more than happy to jump in and help out!

Was this page helpful?
0 / 5 - 0 ratings