DEV Community

Cover image for How to stop chatbots from killing your page speed
Joseph Farruggio
Joseph Farruggio

Posted on

2

How to stop chatbots from killing your page speed

When we’re considering JS dependent functionality, we need to weight its benefits against its costs. Chat bots are powerful support and lead gen tools, but like any JavaScript resource it adds weight to your web page, slows TTI, and delays other resources from loading.

And another thing to consider is that fact that folks don't need a chatbot the second they hit your webpage. They need a second or two to take it all in and figure out what they are going to read or click on next. So why are we forcing folks to download chatbots in a way that's not performant and doesn't serve their needs?

That's why I both wrote a tutorial on how to optimize chatbot's for page speed via JavaScript and built a WordPress plugin called Chatbot Lazy Loader to do that work for you.

What's happening in the JavaScript is delightfully simple. Our JavaScript is delaying the download of the chatbot's JavaScript. And there's more than one way we can implement this.

  1. We could set a timer and make the chatbot JavaScript wait 5 seconds.
  2. We could create an event listener to detect when the user begins to scroll.
  3. We could also prevent the chatbot's JavaScript from loading entirely and wait for the visitor to hover or click on a "Chat with us" button.

The end result is the same though. You get to protect your page speed score and improve your visitor's experience.

Cheers!

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay