Search code examples
htmlcalendly

Calendly slowing website, because of script


After integrating Calendly into my website caused a decrease of page speed.

The first thing, I tried was to add async and defer at the end of script

<script type="text/javascript" src="https://assets.calendly.com/assets/external/widget.js" defer></script>

But it doesn't improve speed, so what should I do to improve the speed of page?


Solution

  • So I have done it with javascript, and It improved speed from 40 to 80 points. Basically that loads Calendly after a few seconds, so It doesn't slow the page at the beginning.

    window.onload = function() {
     window.setTimeout(function () { 
      var script = document.createElement('script');
      script.async = true;
      script.src = 'https://assets.calendly.com/assets/external/widget.js';
      document.querySelector('head').appendChild(script);
     }, 3000);
    };