DEV Community

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

Posted on

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!

Top comments (0)