Skip to content

Commit

Permalink
Removed unnecessary conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
jeawhanlee committed Jan 21, 2025
1 parent 7765036 commit 7aff6de
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions inc/Engine/Common/PerformanceHints/Frontend/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,10 @@ private function inject_beacon( $html, $url, $is_mobile ): string {
$script_url = rocket_get_constant( 'WP_ROCKET_ASSETS_JS_URL' ) . 'wpr-beacon' . $min . '.js';

// Create the script tag.
$script_tag = "<script data-name=\"wpr-wpr-beacon\" src='{$script_url}' async></script>"; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
$body_tag = strrpos( $html, '</body>' );

if ( false !== $body_tag ) {
// Append the script tag just before the last closing body tag especially in cases where there's an iframe.
$html = substr_replace( $html, $inline_script . $script_tag . '</body>', $body_tag, 7 );
}
$script_tag = "<script data-name=\"wpr-wpr-beacon\" src='{$script_url}' async></script>"; // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript
$last_body_tag_position = strrpos( $html, '</body>' );
// Append the script tag just before the last closing body tag especially in cases where there's an iframe.
$html = substr_replace( $html, $inline_script . $script_tag . '</body>', $last_body_tag_position, 7 );

return $html;
}
Expand Down

0 comments on commit 7aff6de

Please sign in to comment.