Pagespeed insights - how to make it work

We are facing some issues with pagepeed insights and drift. it's very heavy on our page-load therefore our score just went down dramatically.

The main offenders:

  1. the font
  2. the JS payload is huge.

We can't afford to load by scroll or click since we need our users to see the widget when they come to our site. we tried to delay the load of the code to the end of our loading process but still, google sees it as an excessive amount of JS.

This article shows how to improve:

but honestly, it throws the responsibility back on the dev since it gives the obvious choices to the loading event.

Any guidance will help here.


  • Hi there!

    Sorry to hear you're experiencing loading speed issues with Drift. Looking at the Drift script file on site I see you've set the time delay you mentioned within an IIFE. I'd like to explore another option with you, instead of wrapping the Drift snippet within an IIFE, try wrapping your code with a regular function and then set the time delay to invoke this function after the widget has loaded.

    For example:

    See if this helps your pagespeed insights score. Please let me know! Have a good one!

  • You have a small error in your code but i can do something with the suggestion. testing now.

  • Doesn't look like it helped a lot. Google still sees drift as a problem when it comes to font visibility (no fallback for this Brandon font) and js execution time is affected dramatically.

    Any suggestion is welcome here.


    edited January 2021

    Did some more work and came back with some good insights!

    1. yes, The jsfiddle code actually worked well but we needed to increase the timeout to 2.5 seconds for it to go out of google's eyesight.
    2. For other third parties (not drift) We also implemented a timer trigger on GTM that allows us to run code 3 seconds after js starts to run. 3s seems to be a magic number that moves code far enough for google to ignore but for the user not to feel like a delay in loading is being performed.
    3. if you don't give enough timeout, google might see the drift code as an unused payload. this lowers the score too.

    Hope it helps other people


  • Hi Yaron!

    My apologies for the syntax error I didn't catch that but I'm glad it helped out a bit! You came back with really great insights that I was not aware of. Thank you for sharing your findings with us, this will definitely help others and myself in the future!

    Thanks for posting and feel free to reach out if there's anything else you come across!


    Miguel - Technical Support