Skip to content

Commit

Permalink
WebVitals: Remove dataset, make solution more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
mehigh committed Apr 14, 2021
1 parent a732e62 commit eb73f22
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion php/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ public function enqueue_scripts() {
var randNumber = Math.random();
if ( randNumber <= window.webVitalsAnalyticsData.chance ) {
requestIdleCallback( function() {
webVitalsAnalyticsScript = document.getElementById( 'web-vitals-analytics-js' );
webVitalsAnalyticsScript = document.querySelector( 'script[data-src*=\"web-vitals-analytics.js\"]' );
webVitalsAnalyticsScript.src = webVitalsAnalyticsScript.dataset.src;
delete webVitalsAnalyticsScript.dataset.src;
} );
}
}
Expand Down

0 comments on commit eb73f22

Please sign in to comment.