Solved

Why does Klaviyo Javascript take longer to load?

  • 22 April 2021
  • 9 replies
  • 888 views

Badge +1

Hi, 

 

before I installed Klaviyo, I wouldn’t say my site was perfect, but I would get a healthy B grade from pagespeed etc.

 

Now I get an F, and the only reason for that is Klaviyo’s javascript taking 9 seconds to load. Even loading Asynchronously, which appears to be the stock answer, it is the longest loading part of the page load.

Even the Image for the signup form pop up loads slowly, and I optimised that image to make it as small as possible.

My server is in Singapore, do you have any CDNs in the area?

Is it possible to install the javascript and image locally on my server so I don’t have the long load time?

 

I’m using woocommerce BTW.

 

Thanks

 

Steve

 

icon

Best answer by cassy.lee 4 May 2021, 21:15

View original

9 replies

Userlevel 2
Badge +1

Hey Steve, this is Hansen from Klaviyo. 

 

9 seconds is the slowest I’ve ever heard! Would you be able to share details of your PageSpeed results? I ran a test on your site and the results aren’t as bad (Klaviyo took ~220ms) but I’m not sure if it’s location-dependent since I’m in the US. 

Badge +1

Can you try GTMetrix and use Hong Kong as the location?

 

2nd and 3rd lines

 

Userlevel 1
Badge +1

I agree with 

All Klaviyo js files are huge not optmized. Loading the js libraries cost almost 1MB download for each new customer

Badge +1

Hi @hansen ,

any update on this?

As far as I can see implementing a CDN for at least a few parts of the world might be the best bet.

It seems Honk Kong and Malaysia have similar timings, so I would imagine South East Asia in general will suffer this issue.

Or better still, if we are using wordpress, would it be possible for us to host our own files? As I also see a really slow clunky load of the popup images as those images also come from Klaviyo, and I’ve optimised them down to a very small size.

 

Thanks

 

Steve

Badge +1

nothing? :rolling_eyes:

Userlevel 6
Badge +8

Hi @skabrnes and @David B.

Thanks so much for your patience while I investigated this further! I chatted with @hansen on this and, as I mentioned to @David B. in another post around loading times for .js files, our team is currently investigating ways to improve our JS performance and prioritizing work in this area.

@skabrnes regarding your questions above on Wordpress and hosting your own files…we don’t recommend that you host your own files, because if you self host, we can’t guarantee that Klaviyo features, such as forms, will continue to work properly. You could, however, upload smaller images to the Klaviyo asset library and use that to alleviate some of the loading time issues. Our team is discussing better ways to help our customers with image optimization and reduce JS sizes. We will provide an update when we learn more from the team.

Thanks so much, and we appreciate your patience on our response! 

Userlevel 6
Badge +26

@skabrnes I've actually played around with hosting them on my own site running from main domain instead of klaviyo.com domain and it did seem to work but as @cassy.lee mentioned it's not recommended. You'd need to make sure all files are always up to date etc. So wouldn't do this on production.

Also, loading custom fonts and big images in popups can sometimes also create a slowdown. Not sure if the amount of popups you have in Klaviyo (disabled or not) will also create speed issues? 

 

our team is currently investigating ways to improve our JS performance and prioritizing work in this area.

Has there been any update on this ?

Userlevel 6
Badge +51

Hi @clicklabsdev

 

Thanks for sharing your question with us!

 

I’m not sure if you’re aware, but this Help Center Article about site speed reports and klaviyo.js has been created to explain this issues since topic creation that might be helpful and a publishing of our improvement on form success with this issue!  

I’m not sure what you’ve done to improve your load time so far, but want to echo @Omar’s awesome suggestion of making sure you have only one signup form live on each page as more signup forms you use per page the slower it gets. 

Next, I see that you have injected our onsite script through your integration settings here: https://www.klaviyo.com/integration/shopify

Additionally, as injecting our onsite script through our integration settings is an option for ease of use, you can improve your page load speed by unchecking this option and Manually Install klaviyo.js for Shopify Stores to your theme.liquid file before the closing </body> tag. Here's your script required for manual installation: 

 

<script async type="text/javascript" src="//static.klaviyo.com/onsite/js/klaviyo.js?company_id=COMPANYID"></script>

 

Thanks for participating in the Community and bringing visibility to this so I could share more! 

-Taylor 

Reply