Title: script causing slow page load
Last modified: April 1, 2021

---

# script causing slow page load

 *  Resolved [anjoid](https://wordpress.org/support/users/anjoid/)
 * (@anjoid)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/)
 * Hi, when I have your plugin activated my site speed slows down.
 * The slow script appears to wp-admin/admin-ajax.php?action=wooptpm_get_cart_items
 * Is there anyway to prevent this from slowing things down?
 * See here: [https://prnt.sc/111t43n](https://prnt.sc/111t43n)

Viewing 11 replies - 1 through 11 (of 11 total)

 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14266255)
 * Hi [@anjoid](https://wordpress.org/support/users/anjoid/)
 * That’s a call that happens after page load and therefore doesn’t slow down page
   load or rendering of the page.
    -  This reply was modified 5 years, 1 month ago by [alekv](https://wordpress.org/support/users/alekv/).
 *  Thread Starter [anjoid](https://wordpress.org/support/users/anjoid/)
 * (@anjoid)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14266435)
 * I’ve disabled it and page is faster and scoring higher on speed tests. The script
   is will active on pages such as check just disable on product pages.
 * Do you know if it’s necessary on product pages?
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14267138)
 * > Do you know if it’s necessary on product pages?
 * We can’t render the cart server side because we would run into issues with caching
   mechanisms that cache HTML and would not output the correct cart content. So 
   yes, we need to load this on every page for each visitor individually.
 * We run that function on the `document.ready` event, which in my opinion is safe
   and would not interfere with effective page load speed, because the function 
   doesn’t interact with the visible elements of the page.
 * Having said that, thanks to your report I did some more research. Apparently 
   PageSpeed Insights for instance counts everything into the load time that happens
   before the `document.load` event. (More info [here](https://webmasters.stackexchange.com/a/39512/51846)
   and [here](https://stackoverflow.com/a/4584475/4688612).) That means `document.
   ready` is too early for PageSpeed Insights.
 * I’ll move the function call to after `document.load`, then the pagespeed test
   should be fine.
 * Probably this will be published with the next version in a week or so.
    -  This reply was modified 5 years, 1 month ago by [alekv](https://wordpress.org/support/users/alekv/).
 *  Thread Starter [anjoid](https://wordpress.org/support/users/anjoid/)
 * (@anjoid)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14269407)
 * Awesome sounds good thanks for the update!
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14279048)
 * [@anjoid](https://wordpress.org/support/users/anjoid/)
 * The new version with the fix is out. Let me know if it improves pagespeed measurements
   for you.
 *  Thread Starter [anjoid](https://wordpress.org/support/users/anjoid/)
 * (@anjoid)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14299343)
 * Hey still shows the longest load time [https://prnt.sc/118bn1r](https://prnt.sc/118bn1r),
   I’m going to do some more a/b testing
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14299350)
 * The Ajax call itself will never be fast.
 * The question is, if it happens during page load where the call can block and 
   delay page load and rendering, or if it happens after.
 * The way how it is implemented now, it is for sure loading after the page loaded,
   so it won’t delay anything.
 * What’s the website in question? You can send it to [support@woopt.com](https://wordpress.org/support/topic/script-causing-slow-page-load/support@woopt.com?output_format=md)
   if you want.
 *  [cometto](https://wordpress.org/support/users/cometto/)
 * (@cometto)
 * [5 years ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14372116)
 * hello [@alekv](https://wordpress.org/support/users/alekv/)
 * I found similar problem like OP wrote.
 * ?action=wooptpm_get_cart_items is slowing down website about 1,2-1,5s.
 * Does new update should solve this problem? I tried to find solution in the web
   but didnt get anything interesting
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [5 years ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14372842)
 * Hi [@cometto](https://wordpress.org/support/users/cometto/)
 * The `?action=wooptpm_get_cart_items` call happens **after** the browser has signalled
   the load event, which happens when all content has already been successfully 
   loaded.
 * > The load event is fired when the whole page has loaded, including all dependent
   > resources such as stylesheets and images.
 *  [Reference](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)
 * > PageSpeed measures the loading time of your page starting from the initial 
   > request to when the last embedded resource (JS, CSS, images, etc.) has finished
   > loading. So that’s essentially when $(window).load() is triggered.
 *  [Reference](https://webmasters.stackexchange.com/a/39512/51846)
 * So the `?action=wooptpm_get_cart_items` doesn’t slow down the download or rendering
   of your website in any way.
    -  This reply was modified 5 years ago by [alekv](https://wordpress.org/support/users/alekv/).
 *  [alfrescoid](https://wordpress.org/support/users/alfrescoid/)
 * (@alfrescoid)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14743639)
 * Hi, thanks for this plugin, however, I’ve discontinued using it after a couple
   of days because I noticed my PageSpeed Insights/Lighthouse scores were significantly
   affected when it is active.
 * For example, a product page was getting 78 (mobile) & 97 (desktop) on PSI dropped
   down to 50 (mobile) & 91 (desktop).
 * I ran tests several times to ensure caching etc weren’t the issue. Mobile is 
   clearly the most affected, and it appears that increases in Time to Interactive
   and Total Blocking Time are the reason for the lowest score on mobile test.
 * With the plugin enabled, I get 6.8s for Time to Interactive, and 410ms for Total
   Blocking Time. Without plugin active, I get 3.0s and 0ms respectively.
 * I’d love to know if this if fixable.
 * Best regards,
    Mike
 *  Plugin Author [alekv](https://wordpress.org/support/users/alekv/)
 * (@alekv)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14743763)
 * Hi Mike
 * I assume you were using mainly the Google pixels.
 * My plugin injects the scripts **exactly** as specified by Google, plus it adds
   a few very lightweight scripts of its own (which PageSpeed Insights doesn’t report).
   Ironically PageSpeed Insights mainly complains about the Google tracking scripts.
 * But, if you want to track your visitors, and generate revenue by running successful
   campaigns, then you’ll have to track the visits correctly. So you have to use
   tracking scripts, one way or the other.
 * You can try switching to Google Tag Manager. But, it is much more complex to 
   set up correctly and not as easy to adjust when new pixel features are released.
   At the same time it’s not a guarantee that the scripts load faster using the 
   GTM. It is essentially loading the same scripts. (Or even better you switch to
   server side GTM. But that’s even more complex to set up and comes with additional
   cost.)
 * PageSpeed Insights isn’t perfect in two ways.
 * 1. From what I can tell it essentially uses a points based system to tell you
   if the website loads fast or not. The problem with that is, that it doesn’t measure
   what the real end user experience is. It can be off by a huge margin, but pages
   still load just fine and fast. I therefore like much more using [https://www.webpagetest.org/](https://www.webpagetest.org/).
   It uses a real world approach in a way that it measures what the visitor actually
   sees and it doesn’t weigh resources (such as scripts) that don’t affect the visual
   representation and rendering time.
 * 2. Secondly PageSpeed Insights doesn’t tell you how much more or less money you
   make with your website based on its score. If the score is just 50%, does it 
   mean you make only 50% revenue with your campaigns? No, absolutely not! In the
   contrary. If using a specific script slows down the website a little, but generates
   more revenue, then what’s that PageSpeed Insights score worth to you?
 * 3. PageSpeed Insights only tells you what it sees on the first page load. But**
   all** the scripts get cached by the browser after the first page load. That means
   loading the scripts is a lot faster while the visitors browses your shop.
 * Then, there are methods to trick PageSpeed Insights to think those scripts are
   not being loaded. Many JavaScript optimization tools do that. But, they all impact
   measurement accuracy, sometimes even break tracking entirely. That’s bad for 
   every paid ads campaign performance big time.
 * There is no perfect world. If you want to measure your traffic, optimize your
   campaigns and optimize your campaign revenue **you have to measure your traffic
   correctly**.
 * At the end it comes down to striking the right balance and finding out what increases
   your chances to generate most revenue. If you don’t run any paid ads campaigns
   and it’s not important to you if your website generates revenue, then you don’t
   need a good tracking set up.
 * But, if you generate revenue with your shop and run campaigns with a decent budget,
   then you want to have a tracking solution that is working really well, even if
   it doesn’t satisfy PageSpeed Insights perfectly. So basically you have to ask
   yourself, if by adding tracking scripts and increasing the page load time a little
   bit, will you make more or less money.
 * That’s a question that only you can answer. PageSpeed Insights is not made to
   answer that question.
 * Regards
    Aleksandar
 * PS: Next time please create a new thread for your own question. It’s a forum 
   rule.
    -  This reply was modified 4 years, 9 months ago by [alekv](https://wordpress.org/support/users/alekv/).
    -  This reply was modified 4 years, 9 months ago by [alekv](https://wordpress.org/support/users/alekv/).
    -  This reply was modified 4 years, 9 months ago by [alekv](https://wordpress.org/support/users/alekv/).

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘script causing slow page load’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce-google-adwords-conversion-tracking-tag/assets/
   icon-256x256.png?rev=2704744)
 * [Pixel Manager for WooCommerce – Conversion Tracking, Google Ads, GA4, TikTok, Dynamic Remarketing](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-google-adwords-conversion-tracking-tag/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-google-adwords-conversion-tracking-tag/reviews/)

 * 11 replies
 * 4 participants
 * Last reply from: [alekv](https://wordpress.org/support/users/alekv/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/script-causing-slow-page-load/#post-14743763)
 * Status: resolved