10 Pro Tips for Managing the Performance of Your Third-Party Scripts
10 Pro Tips for Managing the Performance of Your Third-Party Scripts
Here are 10 sweet tips for flipping the script, and managing third-party script performance, such as checking where third parties are served from, and enabling cache timeouts.
Join the DZone community and get the full member experience.Join For Free
Maintain Application Performance with real-time monitoring and instrumentation for any application. Learn More!
A typical web page today can contain upwards of 75 third-party scripts, such as ads and analytics beacons. If you care about web performance, these scripts can be the bane of your existence. But third parties aren’t going away. They add value to site owners by generating revenue (ads), increasing conversions (targeting beacons), and helping you understand your users in unprecedented ways (analytics tags).
The best thing you can do is take a strong proactive approach to mitigating any potential performance damage your third parties may generate.
Last month, I was invited to speak at WebPerfDays Amsterdam. I stayed for the breakout sessions, and I’m glad I did. One of the sessions focused on managing third-party performance, where pros like Andy Davies and Perry Dyball shared some best practices that were too good not to pass along.
Before You Deploy a New Third-Party Script…
1. Calculate its ROI
Perform an A/B test of your pages, with and without the script. Use a synthetic measurement tool, such as WebPagetest, to generate waterfall charts for both versions, and identify how long the third-party scripts take to load. Note these benchmarks.
From the third-party vendor, get the number for the average conversion rate increase experienced by other sites that use the tool. Using Aberdeen’s widely accepted performance stat that a 1-second page delay equals a 7% loss in conversions, calculate the potential net conversion gain or loss. For example, if a tool slows down page load by 2 seconds, that means a 14% conversion loss. But if that same tool promises a 20% conversion increase, then that’s a net gain of 6% (not including the cost of purchasing the tool).
Use this ROI calculation to determine if a specific script ultimately helps your business.
2. Check Where Third Parties are Being Served From
If most of your visitors are in the UK, but your third-party script is hosted in the US, that could incur a hefty latency delay. Talk to your third-party provider about using a content delivery network (CDN) to cache third-party assets closer to your users.
3a. Design and Implement With Failure in Mind
There’s no such thing as 100% uptime. Everyone has bad days, and third party scripts are no exception. What will happen to your pages if a given script goes down? (You can easily simulate this in WebPagetest under the “SPOF” tab in the advanced settings. ) You need to factor this into design and implementation. Will you serve third party scripts asynchronously? Or alternatively, serve them in a non-blocking fashion? If that’s not an option (as in the case of some analytics tags or ad scripts), then will you set timers on your scripts to allow for a set waiting time before the script times out and the rest of the page can resume loading?
3b. Enable Cache Timeouts
(Hat tip to Philip Tellis for suggesting this new tip). Many third-party scripts disable script caching or have very short timeouts (less than an hour). These scripts should have timeouts that span multiple days. This way they can weather spot sales, marketing campaigns, and other traffic spikes.
After You’ve Added the Script…
4. Measure its Impact on Performance and Your Business
This is an evolutionary leap from tip #1 near the top of this post. Instead of using synthetic measurement tools, use your own user data (via real user monitoring tools) to measure the actual impact of third-party tools on your business. This lets you do several great things simultaneously, such as:
- Determine if the third-party script is slowing down your pages.
- If the script is slowing down your pages, determine if this slowdown is hurting metrics like bounce rate, time on site, and conversion rate.
- Regardless of whether or not the third-party script is slowing down your pages, gauge the impact of the script on business metrics, as above.
5. Generate a Request Map that Exposes Fourth-Party (and Fifth-Party, and So On) Calls
Use a third-party analysis tool to generate a request map and expose extended calls. For example, this request map, generated using Ghostery, illustrates long redirect chains triggered by third-party calls on Monster.com. I looked at the waterfall that this map is based on, and I counted 40+ calls in just one chain — possibly the longest redirect chain I’ve ever seen. (If you’ve seen longer, let me know. I’d love to see it.)
Whether a third-party script triggers a fourth-party call or a fortieth-party call, that call doesn’t just introduce additional latency. It also has the potential to hurt your business — and your users — in other ways:
- Exposes you to data leakage
- Generates content security warnings that alarm your visitors and kill your conversions
- Hurts your Google search rankings (SEO)
- Makes your site vulnerable to man-in-the-middle security attacks
6. Detect When Your Third-Party Scripts Change
A while back, I shared a dozen performance best practices from Nordstrom. This one really stood out:
Most third-party vendors will go into lockdown along with you during the holidays, but your vendors might not be aware of your special events. They might plan changes that could have an impact on your site.
To illustrate: One year, during Nordstrom’s anniversary sale, Gopal’s team realized that their order management system wasn’t processing orders any more. After much digging, they discovered that the vendor they used for fraud checks had implemented a change to the service just hours before the start of the sale — and this change was blocking all orders. Now Nordstrom lets all vendors know about its anniversary sale well in advance.
7. Give Feedback to Third-Party Providers
I’ve been a longtime advocate of this practice. Sometimes third-party vendors don’t know their script is suffering from performance problems. Letting them know is the right thing to do.
Cheats and Workarounds
8. Cache Social Media Metrics to Simulate Social Numbers Without Sacrificing Performance
This is a nifty little hack. If social metrics are a must-have on your pages, but you don’t like the performance penalty/risk they can incur, one person in the WebPerfDays breakout session offered this tip. You simply update your metrics periodically or during off-peak times instead of in real time.
9. Instead of Using Third-Party Analytics, do Your Own A/B Testing Server Side
Not everyone has the means to take this on, but if you can, this is a great suggestion from Perry Dyball.
10. Disable the Script During Peak Traffic Times
One breakout participant shared that his team simply disabled problematic scripts during known busy times. This one was a bit controversial (no surprise). For example, if the purpose of your script is to give you insights into your customers, then disabling it when many of your customers are visiting your site is obviously not good. Ultimately, WebPerfDays attendees tended to agree that this tactic is okay in an emergency, but not great as standard practice.
What are Your Pro Tips for Third-Party Performance?
This handful of tips was generated by a group of web performance pros in about an hour. While it’s a good start, I’m sure there’s more hard-won wisdom out there. If you have a pro tip that should be added to this list, let me know in the comments.
Published at DZone with permission of Tammy Everts , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.