Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed sass do not store result in DB bug #6557

Merged
9 changes: 7 additions & 2 deletions assets/js/lcp-beacon.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function LCPCandidates(count) {
if (imageURL !== null) {
// Insert element into topCandidates in descending order of area
for (let i = 0; i < topCandidates.length; i++) {

if (area > topCandidates[i].area) {
topCandidates.splice(i, 0, { element, area, imageURL });
topCandidates.length = Math.min(
Expand Down Expand Up @@ -133,10 +133,15 @@ async function main() {
await fetch(rocket_lcp_data.ajax_url, {
method: "POST",
credentials: 'same-origin',
body: data
body: data,
headers: {
'wpr-saas-no-intercept': true
}
})
.then((response) => response.json())
.then((data) => {
const beaconscript = document.querySelector('[data-name="wpr-lcp-beacon"]');
beaconscript.setAttribute('beacon-completed', 'true');
console.log(data);
})
.catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion inc/Engine/Media/AboveTheFold/Frontend/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function inject_beacon( $html, $url, $is_mobile ): string {
$script_url = rocket_get_constant( 'WP_ROCKET_ASSETS_JS_URL' ) . 'lcp-beacon' . $min . '.js';

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

// Append the script tag just before the closing body tag.
return str_replace( '</body>', $inline_script . $script_tag . '</body>', $html );
Expand Down
Loading