To stop 3rd party scripts from running on Google PageSpeed Insights use this code:
<?php
// Stop 3rd party scripts on Google PageSpeed Insightsif (isset($_SERVER['REMOTE_ADDR']) && strpos($_SERVER['REMOTE_ADDR'], '66.249.82') === false ) :?><!-- Write your code here --><?php endif ?>
It checks if the user's IP address is not from Google's crawler and only executes the code if the condition is true. This can help improve your website's page speed score on Google PageSpeed Insights by preventing unnecessary scripts from running during the analysis.
To use this code, simply add it to your website's header or footer. You can add your own code inside the <!-- Write your code here --> comment.
By implementing this code, you can optimize your website's performance and improve your page speed score on Google PageSpeed Insights.
To speed up the loading of Google Fonts, use the preload attribute with the link tag. Here's an example code snippet that demonstrates this optimization technique using the pre HTML tag:
<link rel="preload" href="//fonts.googleapis.com/css2?family=Open+Sans:wght@300;400&family=Poppins:wght@300;400;500;600;700&display=swap" as="style" onload="this.onload=null;this.rel='stylesheet'" />