Late to the party Everything about loading third-party scripts
Slide 2
Edwin Bos Lead Front-End @ Cream
Slide 3
Late to the party Everything about loading third-party scripts, like:
• • • • • • •
conversion trackers visitor behaviour trackers chat widgets YouTube video’s Tag Manager analytics etc.
Slide 4
Late to the party Everything about loading third-party scripts, like:
• • • • • • •
conversion trackers visitor behaviour trackers chat widgets YouTube video’s Tag Manager analytics etc.
Slide 5
Why performance matter A one-second delay in mobile load times can impact conversion rates by up to 20% * Back in 2006, Amazon found that every 100ms in added page load time cost them 1% in sales **
Source: SOASTA,The State of Online Retail Performance, U.S., April 2017. ** http://glinden.blogspot.com/2006/11/marissa-mayer-at-web-20.html
Slide 6
Why performance matter If a slow experience drives customers away, a fast experience can help attract and keep them
Slide 7
Is 100 points at pagespeed the ultimate goal?
Slide 8
Is 100 points at pagespeed the ultimate goal? Pagespeed Insights a good starting point Better insight with Devtools and tools like WebPageTest
Slide 9
The waterfall
Slide 10
But first the low hanging fruits Scripts in tag manager from old site Scripts that are loaded without a subscription Script that do something, but no important for the business Use native functionalities, like the Share API
Slide 11
Use alternative script Load YouTube with Lite YouTube Embed, 224x faster https://github.com/paulirish/lite-youtube-embed
Load Google Analytics 4 with Minimal Analytics 4, just 2kb https://gist.github.com/idarek/9ade69ac2a2ef00d98ab950426af5791?s=09
Slide 12
Avoid render blocking resources
Slide 13
Avoid render blocking resources
Slide 14
Avoid render blocking resources
Slide 15
Avoid render blocking resources
Slide 16
Adobe Typekit example
Slide 17
Preconnect & Prefetch
Slide 18
Pre-connect & Pre-fetch
Slide 19
Host third-party scripts locally This makes a third-party script a rst-party script You can re-download the script every night if they change a lot
fi
Google Fonts is the best example (but not a script)
Slide 20
Load Tag Manager or scripts on user interaction You can load Tag Manager on rst interaction
fi
Or set an event for user interaction
Slide 21
Load Tag Manager on user interaction The moment the user has its rst interaction, the JavaScript get loaded. A user interaction is: Touchstart mouseover, wheel scroll keydown
fi
• • • • •
Load other script on user interaction For example TrustedShops
Slide 35
Load other script on user interaction
Slide 36
Load other script on user interaction
Slide 37
Load chat widget on click How many people do use the chat? Chat widgets are large (500kb - 1MB), created in React or other libraries Load it on click on fake button
Slide 38
Partytown (beta) Get third-party script of the main thread https://partytown.builder.io/
Slide 39
Partytown
Slide 40
Partytown
Slide 41
Client side GTM vs. Server side GTM
Slide 42
GTM server side Browser-based tracking and cookies won’t last long server-side tracking is the future
fi
It can make third-party script, rst-party scripts
Slide 43
GTM server side Only for tracking, analytics, marketing code You still have scripts that needs JavaScript client side It can get expensive (especially if you’re doing it wrong) Server-side tracking can get very technical, very fast
Slide 44
This is the end, beautiful friend
Questions ???
Slide 45
This is the end, beautiful friend https://twitter.com/edwinbos1