ambuda
ambuda copied to clipboard
Self-host all external JS?
Currently, scripts are loaded from a few external sources. E.g. visiting http://localhost:5000/proofing/foo/14/ I see:
- (57.0 kB) https://cdn.jsdelivr.net/npm/[email protected]/build/openseadragon/openseadragon.min.js
- (25.2 kB) https://cdn.jsdelivr.net/npm/@indic-transliteration/[email protected]/sanscript.min.js
- (15.4 kB) https://unpkg.com/[email protected]/dist/cdn.min.js
Would it make sense to cache them all, maybe bundle them into one, and load them ourselves?
Possible benefits:
- Privacy (requests not sent to jsdelivr / unpkg / whatever external source)
- Security and stability (the external website can't change the file under us, to something possibly malicious or broken)
- Will/can work locally without internet, at least not required on every request.
The last one is of most interest to me, as my 3-year-old keeps disconnecting the internet at home 😄 and I'm typing this from unreliable hotel wi-fi.
Possible disadvantages:
- Work to set it up
- More hosting / serving costs
- May be slower than the CDN
I think the pros make sense, and the cons aren't too bad. What I'm curious about is why the CDN versions aren't being cached, as I would expect them all to have long-lived HTTP caches ...
I think the lack of caching was because of turning off caching in the Network tab of Developer Tools:
(Will try without that option…)
IIRC developer tool settings usually take place only if the console is open. But, let me know if that works