{"id":104676,"date":"2023-09-13T10:44:11","date_gmt":"2023-09-13T14:44:11","guid":{"rendered":"https:\/\/www.boldgrid.com\/support\/?p=104676"},"modified":"2024-06-10T12:36:51","modified_gmt":"2024-06-10T16:36:51","slug":"delay-scripts-tool","status":"publish","type":"post","link":"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/delay-scripts-tool\/","title":{"rendered":"How to Use W3 Total Cache Pro Delay Scripts Feature"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><div class=\"flex flex-grow flex-col gap-3 max-w-full\">\n<div class=\"min-h-[20px] flex flex-col items-start gap-3 overflow-x-auto whitespace-pre-wrap break-words\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>Welcome to the W3 Total Cache Pro Delay Scripts feature guide. This feature helps improve your website&rsquo;s performance by delaying the loading of JavaScript resources, thereby eliminating render-blocking issues and boosting your Google PageSpeed scores. In this guide, we&rsquo;ll walk you through how to use Delay Scripts effectively for optimizing your website&rsquo;s performance. Let&rsquo;s dive into the details and get started<\/p>\n\t  \n\t<div class=\"bg-proof bg-shadow\">\n\t\t<div>\n\t\t\t<span class=\"bg-green-circle\">+14<\/span>\n\t\t\t<span class=\"bg-green-description\">Points<\/span>\n\t\t<\/div>\n\t\t<div>\n\t\t\t<p>In this test, using the Delay Scripts feature alone added +14 points for a 26% increase on mobile devices to the <strong>Google PageSpeed Performance score<\/strong>! <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/pagespeed-tests\/delay-scripts-test\/\">Review the testing results<\/a> to see how.<\/p>\n\t\t\t<p>\n\t\t\t\t<a class=\"button-primary\" href=\"https:\/\/www.w3-edge.com\/checkout-standalone-1\/?utm_source=boldgrid&amp;utm_medium=support-on-page&amp;utm_campaign=BoldGrid\" style=\"background: #21759b;padding: 6px 10px;\">Upgrade to W3 Total Cache Pro<\/a> and improve your PageSpeed Scores today!\n\t\t  \t<\/p>\n\t\t\t<div class=\"bg-proof-meta\">\n\t\t\t\t<div><strong>Audit:<\/strong> Google Mobile PageSpeed Score<\/div>\n\t\t\t\t<div><strong>Before:<\/strong> 54.25.<\/div>\n\t\t\t\t<div><strong>After:<\/strong> 68.5<\/div>\n\t\t\t<\/div>\n\t  \t<\/div>\n\t<\/div>\n\t  \n    \n<h2 id=\"enabling-delay-scripts\">Enabling Delay Scripts<\/h2>\n<\/div>\n<\/div>\n<\/div>\n<p>The first step to using the Delay Scripts feature is to enable the feature by navigating in your WordPress admin to <strong>Performance &gt; General Settings<\/strong> and then clicking on the sub-nav <strong>User Experience<\/strong>. <span style=\"font-weight: 400;\">Once there, click on the <\/span><b>Delay Scripts <\/b><span style=\"font-weight: 400;\">checkbox to enable it and then click on <\/span><b>Save Settings<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-5-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-108484 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-5-2.png\" alt=\"\" width=\"1335\" height=\"95\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-5-2.png 1335w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-5-2-300x21.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-5-2-1024x73.png 1024w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-5-2-768x55.png 768w\" sizes=\"auto, (max-width: 1335px) 100vw, 1335px\" \/><\/a><\/p>\n<div class=\"alert alert-info\"><strong>Note: <\/strong>For best performance, it is recommended to enable the <strong>Minify<\/strong> feature to optimize all internal JS resources and to use the <strong>Delay Scripts<\/strong> feature to delay all external JS resources as well as any internal JS resources excluded from <strong>Minify<\/strong>. Using both features in this manner should yield the highest impact on performance and Google PageSpeed rankings.<\/div>\n<h2 id=\"configuring-delay-scripts\">Configuring Delay Scripts<\/h2>\n<p><span style=\"font-weight: 400;\">The next step is to configure the feature by navigating to <\/span><b>Performance &gt; User Experience<\/b><span style=\"font-weight: 400;\">. There will be a new setting block called <\/span><b>Delay Scripts<\/b><span style=\"font-weight: 400;\"> towards the bottom of the page.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The <\/span><b>Timeout<\/b><span style=\"font-weight: 400;\"> field controls the delay the page will wait after fully rendering the content before loading any delayed scripts defined in the <\/span><b>Delay List<\/b><span style=\"font-weight: 400;\">. This delay can be interrupted by any user interaction with the page however which will cause delayed scripts to load immediately. This is done to prevent errors and to ensure the required scripts are available for interactivity.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The <\/span><b>Delay List<\/b><span style=\"font-weight: 400;\"> textarea takes one entry per line and is used to define scripts you wish to delay. These values can be any attribute of a &lt;script&gt; tag and are matched exactly so case\/format matters. The best attribute to match on would be the url attribute and can be as simple as the file name. For example <em>googletagmanager.com<\/em>,<em> gtag.js<\/em>, <em>myscript.js<\/em>, <em>name=&rdquo;myscript&rdquo;<\/em>, etc.<br>\n<\/span><\/p>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-2-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-108485 size-full\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-2-2.png\" alt=\"\" width=\"1400\" height=\"600\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-2-2.png 1400w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-2-2-300x129.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-2-2-1024x439.png 1024w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-2-2-768x329.png 768w\" sizes=\"auto, (max-width: 1400px) 100vw, 1400px\" \/><\/a><\/p>\n<h2 id=\"does-delay-scripts-work-with-minify\">Does Delay Scripts Work With Minify?<\/h2>\n<p><span style=\"font-weight: 400;\">Any script that is matched from the <\/span><b>Delay List<\/b><span style=\"font-weight: 400;\"> will automatically be excluded from the minify process. Both the <strong>Delay Scripts<\/strong> feature and the <strong>Minify<\/strong> feature are independent of each other and as such both features can be used interchangeably without conflict.<\/span><\/p>\n<h2 id=\"what-scripts-should-be-delayed\">What Scripts Should Be Delayed?<\/h2>\n<p><span style=\"font-weight: 400;\">One of the easiest ways to identify scripts that should be delayed is to use the W3 Total Cache Google PageSpeed<\/span> <span style=\"font-weight: 400;\">tool whose documentation can be found <\/span><a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/google-pagespeed-tool\/\"><span style=\"font-weight: 400;\">here<\/span><\/a><span style=\"font-weight: 400;\">. Once you authorize and analyze your website, review the <\/span><b>Eliminate render-blocking resources <\/b><span style=\"font-weight: 400;\">metric breakdown which will list both CSS and JS files. These JS files can be added to the <\/span><b>Delay List <\/b><span style=\"font-weight: 400;\">setting.<\/span><\/p>\n<p><a href=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-106019\" src=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-4.png\" alt=\"\" width=\"1388\" height=\"361\" srcset=\"https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-4.png 1388w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-4-300x78.png 300w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-4-1024x266.png 1024w, https:\/\/www.boldgrid.com\/support\/wp-content\/uploads\/2023\/09\/ds-4-768x200.png 768w\" sizes=\"auto, (max-width: 1388px) 100vw, 1388px\" \/><\/a><\/p>\n<div class=\"alert alert-info\"><strong>Note: <\/strong><span style=\"font-weight: 400;\">If you have the <strong>Minify&nbsp;<\/strong>feature enabled and see minified files under this Google PageSpeed section,&nbsp;<strong>do not&nbsp;<\/strong>add them to the&nbsp;<strong>Delay List<\/strong>. Instead, the <strong>Minify<\/strong> feature includes a setting to defer\/async the loading of minified files which should address them being flagged as render-blocking.<\/span><\/div>\n<div><\/div>\n<h2 id=\"how-can-i-confirm-that-scripts-are-being-delayed\">How Can I Confirm that Scripts are being Delayed?<\/h2>\n<p>After configuring the Delay Scripts feature, visit your website and observe the loading behavior. Scripts specified in the Delay List should load after the page&rsquo;s main content. You might notice faster initial load times, as render-blocking scripts are delayed.<\/p>\n<p>Open your browser&rsquo;s developer tools and monitor the network activity as your page loads. Look for the scripts you&rsquo;ve added to the Delay List and check their loading timing. These scripts should be loading after the main content of your page and possibly after a user interaction if you&rsquo;ve set a delay that waits for such interaction.<\/p>\n<p>You can also you a page speed tool like Google PageSpeed Insights before and after enabling Delay Scripts. Compare the scores and look for improvements in metrics related to JavaScript loading times and render-blocking resources.<\/p>\n\t  \n\t<div class=\"bg-proof bg-shadow\">\n\t\t<div>\n\t\t\t<span class=\"bg-green-circle\">62%<\/span>\n\t\t\t<span class=\"bg-green-description\">Decrease<\/span>\n\t\t<\/div>\n\t\t<div>\n\t\t\t<p>In this test, the Delay Scripts feature displayed a 62% decrease in <strong>Time Third-Party Code Blocked The Main Thread For<\/strong> on mobile screens and 37.5% on larger screens in the <strong>Google PageSpeed score <\/strong>results! <a href=\"https:\/\/www.boldgrid.com\/support\/w3-total-cache\/pagespeed-tests\/delay-scripts-test\/\">Check out the testing results<\/a> to see how.<\/p>\n\t\t\t<p>\n\t\t\t\t<a class=\"button-primary\" href=\"https:\/\/www.w3-edge.com\/checkout-standalone-1\/?utm_source=boldgrid&amp;utm_medium=support-on-page&amp;utm_campaign=BoldGrid\" style=\"background: #21759b;padding: 6px 10px;\">Upgrade to W3 Total Cache Pro<\/a> and improve your PageSpeed Scores today!\n\t\t  \t<\/p>\n\t\t\t<div class=\"bg-proof-meta\">\n\t\t\t\t<div><strong>Audit:<\/strong> Time Third-Party Code Blocked The Main Thread For<\/div>\n\t\t\t\t<div><strong>Before:<\/strong> 825 ms<\/div>\n\t\t\t\t<div><strong>After:<\/strong> 197.5 ms<\/div>\n\t\t\t<\/div>\n\t  \t<\/div>\n\t<\/div>\n\t  \n    \n<h2 id=\"how-do-i-debug-issues\">How Do I Debug Issues?<\/h2>\n<p><span style=\"font-weight: 400;\">If JavaScript errors occur after configuring the <\/span><b>Delay List <\/b><span style=\"font-weight: 400;\">the simplest way to identify issues is to use your browser&rsquo;s debug console. This should show you which files are throwing errors. Unfortunately, this can be tricky to debug as some JavaScript code\/files may fail due to dependencies (such as jquery.js) being unavailable or loaded out of sequence so testing removing\/adding scripts may be required to identify which script(s) can&rsquo;t be delayed.<\/span><\/p>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to the W3 Total Cache Pro Delay Scripts feature guide. This feature helps improve your website&rsquo;s performance by delaying the loading of JavaScript resources, thereby eliminating render-blocking issues and boosting your Google PageSpeed scores. In this guide, we&rsquo;ll walk you through how to use Delay Scripts effectively for optimizing your website&rsquo;s performance. Let&rsquo;s dive [&hellip;]<\/p>\n","protected":false},"author":880,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"bgseo_title":"","bgseo_description":"","bgseo_robots_index":"index","bgseo_robots_follow":"follow","footnotes":""},"categories":[747,692],"tags":[],"class_list":["post-104676","post","type-post","status-publish","format-standard","hentry","category-user-experience","category-w3-total-cache"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/104676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/users\/880"}],"replies":[{"embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/comments?post=104676"}],"version-history":[{"count":29,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/104676\/revisions"}],"predecessor-version":[{"id":132638,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/posts\/104676\/revisions\/132638"}],"wp:attachment":[{"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/media?parent=104676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/categories?post=104676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.boldgrid.com\/support\/wp-json\/wp\/v2\/tags?post=104676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}