How to delay the script load in wordpress

is looking for a way to delay the script loading in WordPress?

WordPress users are always looking for cutting -edge technology to improve the loading time of their website. For many factors that create a successful online image, speed is very important. The two main items about WordPress speed are visitors’ experience and search engine rankings.

Many third -party tools can enhance the functions or visibility of the WordPress website. These third -party tools use JavaScript to add their functions to WordPress website.

The disadvantage of this added third -party JavaScript is that in most cases, it increases the page load time of each URL of each script.

This means that no matter your page has a script and a visitor attempts to access the page, the time required to fully load the page will increase due to the script.

Maybe you are not even sure if your website is fast or slow. Check the link below to provide you with information about the speed testing tool for free website speed. You can use these tools to determine the speed of the website.
https://www.wpfixit.com/free-website-dEd-testing-tools/\u003d3]

You must use the function to exchange the speed of speed, isn’t it?


The outer script is costly high on your website page

Third -party scripts are everywhere. According to the JavaScript status report of HTTP Archive, the median of the external script requested by the website is

20 , and their total size is about 449 kb .

The webpage of

93.59% contains at least one third -party resource. The same data in -depth digging shows that 76% website uses analysis scripts to track users.

The most serious impact of a third -party script is the delayed key rendering path, and the Core Web Vitals score that affects your FID level.

[12]3] The key rendering path is a set of operations to combine HTML, CSS, and JavaScript into a living and available website.

Naturally, the effective load size of a third -party script plays an important role here, but there is another important factors that need to be considered.

JavaScript takes up a lot of CPU resources to execute. Even if you optimize third -party scripts to reduce the impact on rendering time, they will still affect the \”interactive time\” indicator. It measures the speed of user interaction with the webpage.

The slower the speed, the more frustrated your users will, the greater the opportunity they give up your website.

The most common outer script on WordPress


The following is the list of some most common outer scripts on the WordPress website. Many of them will recognize because you may use them on your website.

Google Analysis

    Facebook pixel code

  1. Real -time chat small components

  2. Video embedded

  3. Embedded format

  4. Social media widgets

  5. Embedded table

  6. When delayed script loading in WordPress speed.


If we tell you what you can have both? Use a third -party script to enhance your WordPress website’s functions and visibility, and ensure that each page on your website is loaded as fast as possible for your visitors. This is possible, it is completed by loading the script load in WordPress.

Under normal circumstances, when you use the internal script on the website, when the visitor visits your website URL, the script will be loaded with the page.

When you are loaded in WordPress, the outer script will start loading before the delay time period expires.

For example, if you set the delay time to 4 seconds, this means that the script will be executed after 4 seconds after the page is fully loaded.

This is very powerful because this means that page loading will not wait for the script to complete. Your visitor experience will be improved, because the page loading speed is faster, and you use any speed testing tools on a test on the websiteBorn a better result.

Let’s take a look at the difference between the loading and delayed script load of conventional external scripts. Conventional external scripts loaded

The following figure shows the waterfall loading of URL with a trustpilot recommended small component.

As you saw in the picture, this page is loading 5 external requests. These requests come from an outer script.


ordinary external script embedded

Delay Script Load in WordPress
[ 123]
Ordinary external script embedded

WordPress Load Script 1
Load the outer script load Now let’s take a look at load delay in loading in WordPress The same page loaded by the script. This Trustpilot recommended small parts are still embedded in the page, but we set up a delay time to load it 2.5 seconds after the page is loaded.

Not only the request volume decreased, but also the full load time and loading time decreased.

It is like the script is not even on the page during the loading period.

The delayed external script was embedded

WordPress Delay Load Script
The delayed outer script is embedded in

WordPress Delay Load Script 1
Since we have explained the high cost load time of the external script And you can use them without sacrifice, so let us show you the exact code that achieves excellence.

The original loaded script loaded

[ 123] The following code is the default script embedded in the Trustpilot component we use in the above speed test. \u0026 lt;!-Trustbox script-\u0026 gt; \u0026 lt; script type \u003d \u0026 quot; text/javascript \u0026 quot;src\u003d\u0026quot;//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js\u0026quot; async\u003d\u0026quot;\u0026quot;\u0026gt;\u0026lt;/script\u0026gt; \u0026lt;!– End TrustBox script –\u0026gt ; \u0026lt;!– TrustBox widget – Carousel –\u0026gt; \u0026lt;div class\u003d\u0026quot;trustpilot-widget\u0026quot; data-locale\u003d\u0026quot;en-US\u0026quot; data-template- data-businessunit- data-style-height\u003d\u0026quot ;140px\u0026quot; data-style-width\u003d\u0026quot;100%\u0026quot; data-theme\u003d\u0026quot;light\u0026quot; data-stars\u003d\u0026quot;1,2,3,4,5\u0026quot; data-review-languages\u003d\u0026quot;en\u0026quot;\u0026gt ; \u0026lt;a href\u003d\u0026quot;https://www.trustpilot.com/review/wpfixit.com\u0026quot; target\u003d\u0026quot;_blank\u0026quot; rel\u003d\u0026quot;noopener\u0026quot;\u0026gt;Trustpilot\u0026lt;/a\u0026gt; \u0026lt;/div\u0026gt; \u0026lt; !-End trustbox widget-\u0026 gt;

The code below in WordPress is loaded

we use in our speed test above. The delay script of this Trustpilot component is embedded.

   

\u0026 lt;-Trustbox script-\u0026 gt; \u0026 lt; script \u0026 gt; settimeout Function () {var health_id \u003d document.GetelementsBytagname (\u0026 Quot; Head \u0026 Quot;) [0]; VAR Script_element \u003d Document.createElement (\u0026#39; script \u0026#39;); script_element.type \u003d \u0026#39; text/javascript \u0026#39;; // Set external script_element.src \u003d 123] https://widget.trustpilot.com/bootstrap/v5/tp.widget.Bootstrap.min.js

\u0026#39;; Head_id.appendChild (script_element);},

] 2500

); // The time you can adjust the time delay \u0026 lt;/script \u0026 gt; \u0026 lt;!-end the TrustBox script-\u0026 gt; \u0026 lt;! ;\u0026lt;div class\u003d\u0026quot;trustpilot-widget\u0026quot; data-locale\u003d\u0026quot;en-US\u0026quot; data-template- data-businessunit- data-style-height\u003d\u0026quot;140px\u0026quot; data-style-width\u003d\u0026quot;100% \u0026 quot; data-theme \u003d \u0026 quot; light \”data star \u003d\” 1,2,3,4,5 \”data review language \u003d\” en \”\u0026 gt; \u0026 lt;/div \u0026 gt; \u0026 lt;-end Trustbox small parts-\u0026 gt ;

    Any use delay script in WordPress to load   The following code is the default template. You can use it to delay the load script in WordPress. 123]      

There are only two of this template that needs to be changed.

The external script you want to use URL

You want the script time delay \u0026 lt; script \u0026 gt; settimeout (function () {var back_id \u003d document.getelementsBytagName.src \u003d \u0026#39;

URL_FOR_EXTERNAL_SCRIPT

\u0026#39;; Head_id.appendchild (script_element);

  1. 2500
  2. ) ;/ The time you can adjust \u0026 lt;/script \u0026 gt;
     We really hope this articleThe article is helpful to understand how to delay the script load in WordPress.      

You should really use it on any third -party external script you used on the WordPress websiteYou will see that the loading time on the page will decrease immediately, which will help your search engine rankings and overall visitors experience.

If you encounter any problems when you implement any content in this article, please comment below, we can see the problems you encounter.

Author:

Leave a Reply

Your email address will not be published. Required fields are marked *