has developped into a handy habit for me during development, and lately also for deployment of finished projects onto my private, nonprofit blog. It allows for easy switching between releases and it works well - until it doesn’t!
I’m currently running into non-availability issues because unpkg.com seems not to be available - at least it’s not responding within the Safari timeout of 2 minutes. Which inherently leads to all my Three.js related projects simultaneously breaking down on my website
So I’m wondering, if the usage of CDNs for deployment is such a good idea after all?
If i find myself needing to load something from one of those CDNs, i just download it the first time, then in network tab of chrome, “Save as” the library right into my app.
The cdn promise of distributed loading and paralellism is a lie. They always load slow… and have longer startup times. If its local… all your file io is going to perform consistently.
For quite some time unpkg.com has been degrading in terms of response time and availability. I used to use it in the past, but now I use jsdelivr.net. No issues so far.
In some cases, however, I prefer to put the files locally, but this happens quite rarely nowadays. As for bundling - I dislike it on some irrational level. I understand its benefits, but I still cannot start to like it.
As good of an idea as gambling is since you’re already serving your project JS, kinda no reason to rely on third party CDNs instead of just using vite and just bundle dependencies - you’re accepting unnecessary risk at little-to-no gain.
I was suspicious of CDNs right from the start. If they stop working, all examples are no longer immediately executable.
I therefore decided back in 2017 to save the required sources of three.js in the respective revision locally for my collection. Likewise other resources. Of course, this takes some work.
If you download the zip file of a vintage of the collection, you can be sure that all examples will work permanently. (The basic examples, the extended ones are only links, and mostly with the use of CDNs).
Unless the browsers have new requirements again, as was the case with older examples with video texture. They no longer work because user interaction is now required.
Likewise for a long time, then it made sense, npm i three@re.vis.ion saves opening a browser, finding a repo and downloading it, it’s all in the terminal with 100% local control of directories