Skip to content

Commit

Permalink
Fix bail out
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Apr 25, 2024
1 parent 3f46bf6 commit 6040562
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions assets/js/lcp-beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,21 @@ function main() {
data_check.append('url', rocket_lcp_data.url);
data_check.append('is_mobile', rocket_lcp_data.is_mobile);

const response = fetch(rocket_lcp_data.ajax_url, {
const lcp_data_response = fetch(rocket_lcp_data.ajax_url, {
method: "POST",
credentials: 'same-origin',
body: data_check
});

if ( true === lcp_data.success ) {
if ( true === lcp_data_response.success ) {
console.log('Bailing out because data is already available');
return;
}

// Check screen size
const screenWidth = window.innerWidth || document.documentElement.clientWidth;
const screenHeight = window.innerHeight || document.documentElement.clientHeight;

if ( ( rocket_lcp_data.is_mobile && ( screenWidth > rocket_lcp_data.width_threshold || screenHeight > rocket_lcp_data.height_threshold ) ) ||
( ! rocket_lcp_data.is_mobile && ( screenWidth < rocket_lcp_data.width_threshold || screenHeight < rocket_lcp_data.height_threshold ) ) )
{
Expand Down
2 changes: 1 addition & 1 deletion assets/js/lcp-beacon.js.min.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6040562

Please sign in to comment.