Skip to content

Instantly share code, notes, and snippets.

@hasnhasan
Created June 12, 2019 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasnhasan/346b70db17ec1c1bff6ca33bc47157d1 to your computer and use it in GitHub Desktop.
Save hasnhasan/346b70db17ec1c1bff6ca33bc47157d1 to your computer and use it in GitHub Desktop.
$response = $next($request);
$buffer = $response->getContent();
ini_set('zlib.output_compression', 'On'); // If you like to enable GZip, too!
$buffer = preg_replace('~<img(?!.*data-lazyno)[^>]*\K(?=src)~i', 'data-r', $buffer);
$response->setContent($buffer);
$buffer = $response->getContent();
$buffer = preg_replace('~<iframe(?!.*data-lazyno)[^>]*\K(?=src)~i', 'data-r', $buffer);
$response->setContent($buffer);
$buffer = $response->getContent();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment