Skip to content

Commit

Permalink
Minor PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Sep 3, 2024
1 parent c77e44f commit 5c93aed
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ public function __construct( Processor $processor, ContextInterface $context ) {
* @return string
*/
public function optimize( string $html, $row ): string {
$html_without_hashes = $this->remove_hashes( $html );
if ( ! $row->has_lrc() ) {
return $html_without_hashes;
return $this->remove_hashes( $html );
}

$hashes = json_decode( $row->below_the_fold );

if ( null === $hashes || ! is_array( $hashes ) ) {
return $html_without_hashes;
if ( ! is_array( $hashes ) ) {
return $this->remove_hashes( $html );
}

$result = preg_replace( '/data-rocket-location-hash="(?:' . implode( '|', $hashes ) . ')"/i', 'data-wpr-lazyrender="1"', $html, -1, $count );
Expand All @@ -60,7 +59,7 @@ public function optimize( string $html, $row ): string {
||
0 === $count
) {
return $html_without_hashes;
return $this->remove_hashes( $html );
}

$html = $result;
Expand Down

0 comments on commit 5c93aed

Please sign in to comment.