DEV Community

Discussion on: Introducing Partytown πŸŽ‰: Run Third-Party Scripts From a Web Worker

Collapse
cyrstron profile image
cyrstron • Edited on

But where are the actual numbers? What performance boost did you exactly get with this approach?

Isn't DOM accessing and modifying itself is the most expensive part? Does profit of moving everything else except that to a web-worker really worth it?

Also moving data from the main thread to a web-worker and back takes resources as well (for instance, serialization/deserialization).

Collapse
steve8708 profile image
Steve Sewell

We've seen a single third party script for analytics drop a lighthouse score by 20 points. Analytics in particular is a high priority use case as it does not need constant read/write with the main thread (aka it's not needing to constantly serialize/dserialize), it just needs to not throw errors if it tries to run something like if (window.something) { ... }.

With projects like Qwik, Astro, Marko, React server components, everyone is trying to remove (or even eliminate) needing to run JS on the main thread to initialize a site or app, but what we immediately find is your hard work is quickly negated by the amount of 3rd party services that eat the main threads resources that are background oriented anyway (e.g. analytics). Partytown aims to solve for this use case by moving those expensive scripts to the worker and free up the main thread for just your code

Our next step is to gather production data and performance impact of running 3rd party scripts (on real websites) vs not (in partytown or eliminating entirely) to quantify the impact of these scripts more. Will share when we have the data available, so stay tuned :)

Collapse
cyrstron profile image
cyrstron

Sounds great!

Are there only specific use cases for this approach or it may be useful for most of the third party libs?

Thread Thread
steve8708 profile image
Steve Sewell

Absolutely - right now we’re mostly focused on analytics like google tag manager, google analytics, conversion tracking JS, etc.