Max Rozen

Improve your SEO by delaying your marketing scripts

October 23, 2019 • ☕️ 1 min read

Background

The short of it is: adding snippets to your site from common marketing tools like Intercom, Segment, and FullStory slows down your customers’ ability to use your site.

Slow sites get less consideration from Google, as customers are generally more likely to bounce from slow sites.

We can measure the impact of deferring the loading of these scripts using a metric called Time to Interactive (TTI). TTI is one of the core metrics in Google’s Lighthouse tool.

The fix

Add the following code to wherever you load your marketing scripts. Then move your marketing scripts where it says //insert marketing snippets here.

window.addEventListener(
  'scroll',
  () =>
    setTimeout(() => {
      //insert marketing snippets here
    }, 1000),
  { once: true }
);

How it works

By moving your snippets into the setTimeout callback, you delay loading your marketing scripts until after your entire website has loaded. This means your customers see your content faster, and Google gives your site more SEO consideration.

When your customer starts scrolling down your page, after a second your marketing scripts will start loading.

Discuss on TwitterEdit on GitHub

Enjoyed this post? Receive the next one in your inbox!

I won't send you spam.

Unsubscribe at any time.

MaxRozen.com

Max Rozen

Thoughts on business, software, and marketing by Max Rozen [About]