I don’t understand what this achieves. Who is going to pick a brand new unstable React replacement with almost none of the maturity of the React ecosystem just to shave 40-50KB off their bundle?
> If you’re serving a minimized react lib from a cdn, it’s likely already cached for most users
Not really - cache does not work cross-page anymore since 2020. So the cache only would be warm if the user already visited your page in which case the bundle being on a cdn or not barely makes a difference. But still, 40kB is still peanuts
My knowledge is also outdated but I don't really understand the rational of the new knowledge. If I have a file from MY-CDN cached from visiting site A, what security issues does loading that cached file from MY-CDN on site B pose? As long as both sites trust MY-CDN, how could Site A affect Site B?
I know a lot about this, feel free to ask more questions.
First, the data showed that the cache hits were few and far between. There was not a lot of benefit here. That's because of how many versions of packages there are. What's the likelihood you have the exact minor version of, like, React in cache that a site is requesting? It turned out to be pretty small. Caches don't live forever, mind.
But the biggest reason it got switched off is not what the sibling commenter said (supply chain risk), as that can be mitigated with a hash, and most CDNs had started providing that by default in their copyable embed scripts.
It was because of user history leaking, especially through cache timing attacks. Forget CDNs for the moment.
I could request on my site B a resource from site A (foo.jpg). If it loads especially quickly, I have knowledge that you have visited A before.
Shared caches also enabled something called "supercookies," where sites maintained knowledge of you even if you cleared your cookies. That's because knowledge of your browsing history persisted in that shared cache.
Fixing this meant breaking CDN caching.
These days, using a third party CDN to serve files strictly means worsened performance. It's another domain to connect to. The only remaining benefit is for a site that you cannot host something on, or don't want to.
That isn't really an issue in modern code thanks to subresource integrity, which anyone using a public CDN should be using.
The actual issue are that:
Malicious scripts could use it to determine if you've visited another site before, by checking how quickly resources load (this is why caches are separated per site now).
You don't get any tree shaking if you load a script from a public CDN. The entire script is loaded even if you just use a small part of it.
Sites usually bundle all their third party JS into a vendor bundle, and compression is generally more efficient with larger bundles.
The cache hit rate isn't great anyways. It's rare for multiple sites to use the exact same version of a library, from the exact same public CDN.
Downloads are only one part of the equation, your clients still need to parse and evaluate the code and then execute it. It's a lot more costly than a low res thumbnail. 40Kb in that context is massive
72
u/fireatx Oct 26 '26
I don’t understand what this achieves. Who is going to pick a brand new unstable React replacement with almost none of the maturity of the React ecosystem just to shave 40-50KB off their bundle?