0b5vr
March 25, 2024, 3:23am
1
I’m using unpkg.com
for CDN as the installation doc says .
When I do import * as Nodes from "three/addons/nodes/Nodes.js"
for NodeMaterials it takes very long time to download all the referenced js files.
Sometimes it takes 2 or 3 attempts to download because some request returns 502 Bad Gateway.
However, threejs.org
examples served in GitHub Pages are dealing with this relatively fine.
Is there any recommendation against the issue?
0b5vr
March 25, 2024, 9:44am
2
Other than “use a build system like Vite”. I’m working on a public example file for a library that should be done in a raw HTML file.
Hm. Hosting and serving them from your domain? This should require just a small change in the import map.
Arthur
March 25, 2024, 10:50am
4
Have you tried other CDNs?
0b5vr
March 26, 2024, 3:52am
5
Hm. Hosting and serving them from your domain? This should require just a small change in the import map.
Nah that won’t be beautiful as an example. I want to make the html file work standalone.
Have you tried other CDNs?
I suprisingly haven’t tried yet, thank you.
unpkg: Described above, very slow. ~60s when cdn cache misses, 500ms when cdn cache hits. Sometimes responds 502 Bad Gateway
jsDelivr: Best among them. 4s when cdn cache misses, 500ms when cdn cache hits
cdnjs: Doesn’t work, /examples/jsm
are unable to fetch
Skypack: Doesn't work, unable to server-side build since r157
I probably should use jsDelivr as a replacement for now.
0b5vr
March 26, 2024, 9:33am
6
Reported on GitHub Issue, It seems that mrdoob also agrees to switch to jsDelivr
opened 04:16AM - 26 Mar 24 UTC
Suggestion
### Description
unpkg CDN is very slow to load all the dependent modules when w… e're using NodeMaterials, sometimes responds 502 Bad Gateway.
We might want to consider switching the [installation doc](https://threejs.org/docs/#manual/en/introduction/Installation) to jsDelivr, or is there better solution?
I have compared four CDNs, and jsDelivr seems to be the best.
- unpkg: Described above, very slow. ~60s when cdn cache misses, 500ms when cdn cache hits. Sometimes responds 502 Bad Gateway
- jsDelivr: Best among them. 4s when cdn cache misses, 500ms when cdn cache hits
- cdnjs: Doesn't work, `/examples/jsm` are unable to fetch
- Skypack: Doesn't work, unable to server-side build since r157
### Reproduction steps
1. Use unpkg as a Three.js CDN
2. Write a code with NodeMaterial
3. Experience a chill coffee time while loading all the sources, or get mad at 502
### Code
See the demo below.
### Live example
Beware that server-side cache must be missed in order to reproduce the behavior described above.
- unpkg: https://glitch.com/edit/#!/three-r162-nodematerial-unpkg
- jsdelivr: https://glitch.com/edit/#!/three-r162-nodematerial-jsdelivr
### Screenshots
_No response_
### Version
r162
### Device
Desktop
### Browser
Chrome
### OS
Windows
1 Like