• Home
  • About
  • Services
    • Technical SEO
    • Local SEO Services
  • Plugins & Scripts
  • Tutorials Hub
    • Technical SEO
    • WordPress
    • PHP
    • JavaScript
    • Python
    • Google Tag Manager
    • Shopify
    • Other Guides & Tutorials
    • General Discussion
    • View All
  • Contact
    • Hub
      New posts Search forums
    • What's new
      New posts New profile posts Latest activity
    • Members
      Current visitors New profile posts Search profile posts
    Log in Register
    What's new Search

    Search

    By:
    Advanced search…
    • New posts
    • Search forums
    Menu
    Log in

    Register

    Install the app
    • Home
      • Hub
      • Technical SEO
      You are using an out of date browser. It may not display this or other websites correctly.
      You should upgrade or use an alternative browser.

      Delay Execution of JS Scripts with JavaScript

      • Thread starter Chris
      • Start date Sep 12, 2021
      • Sep 12, 2021
      • Replies: 1
      Improve your Google Pagespeed Insights score by delaying the execution of below-the-fold third-party functionality such as commenting scripts, help bots, reCAPTCHA, Share This, Cookie Scripts, and more.

      Async and Defer can really make a massive difference in improving Pagespeed Insights score, to go that extra mile to achieve a higher Pagespeed Insights score (PSI), try this.

      Delay the JS script execution
      Code:
      <script>
      setTimeout(function(){
      loadJs("third-party-script.js");
      },5000);
      </script>

      This script delays "third-party-script.js" for 5000 milliseconds, allowing plenty of time for all the async and defer scripts to load.

      Load after everything else
      Code:
      <script>
      window.onload = function() {
      loadJs("third-party-script.js");
      }
      </script>

      This script will fire after everything else has loaded.

      And lastly, the jQuery DomReady snippet.
      Code:
      <script>
      define(['jquery','domReady!'], function($) {
      
      // Your Code
      
      }(jQuery)
      );
      </script>

      Either of these options will help to improve your Google Pagespeed Insights score. I cannot confirm though if they will improve your Core Web Vitals. I need to gather more data. I will update this post accordingly.
       
      Click to expand...
      C
      Written by

      Chris

      Administrator
      Staff member
      • Messages
        69
      • Reaction score
        1
      • Points
        8
      C

      Chris

      Administrator
      Staff member
      • Oct 6, 2022
      • #2
      PostFor Topic
       
      You must log in or register to reply here.
      Share:
      Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Share Link

      New Posts

      • C
        Bulk Create WordPress Categories using the REST API & Python
        • Started by Chris
        • Nov 3, 2022
        • Replies: 0
        Python Scripts & Tutorials
      • C
        Xenforo API - Bulk Post Threads (Python)
        • Started by Chris
        • Oct 7, 2022
        • Replies: 0
        Python Scripts & Tutorials
      • C
        Xenforo API - Python: Create new Thread
        • Started by Chris
        • Oct 6, 2022
        • Replies: 0
        Python Scripts & Tutorials
      • C
        Xenforo API - Python Reply to Thread
        • Started by Chris
        • Oct 6, 2022
        • Replies: 0
        Python Scripts & Tutorials
      • C
        Bulk Remove Meta Robots Tag using Google Tag Manager
        • Started by Chris
        • Sep 26, 2022
        • Replies: 1
        Google Tag Manager Tutorials & Guides
      • C
        Python Script to Bulk Upload new Wordpress Posts from a CSV file using WordPress Rest API
        • Started by Chris
        • Sep 5, 2022
        • Replies: 0
        Python Scripts & Tutorials
      • C
        Python & WordPress Rest API - Auto Publish a Post
        • Started by Chris
        • Sep 3, 2022
        • Replies: 0
        Python Scripts & Tutorials
      • C
        Screaming Frog v17 - Issues Summary Report & Export
        • Started by Chris
        • Aug 17, 2022
        • Replies: 0
        Technical SEO
      • Hub
      • Technical SEO

    Technical SEO Consultant

    Chris Lever - Freelance SEO Consultant Availible for Hire. Specialist in Technical SEO Audits, Strategy and Implementation.

    Need Help?

    • BB Code
    • Cookie Policy
    • Terms of Use
    • Privacy Policy
    • HTML Sitemap

    Learn More

    • About
    • Availability
    • Popular Posts
    • Projects & Scripts
    • Contact

    Get in Touch

    Chris Lever, Manchester, United Kingdom
    info@chrisleverseo.com
    +44 0161 883 2249

    © 2023 Chris Lever SEO. All rights reserved. Powered by Xenforo

    • This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
      By continuing to use this site, you are consenting to our use of cookies.
      Accept Learn more…