IIRC, this platform uses CDN-hosted libraries rather than bundling/vendoring. As a result, users are exposed to not just outages of the CDNs but also the data collected by these servers. That’s a bummer.
…but it’s not the only bummer. The usage of Highlight.js + MathJax on the front-end is horribly wasteful. Why? It demands all clients parse & render the syntax/LaTeX which is not only taxing on CPUs and batteries, but this action is idempotent meaning every user agent on every page visit is going to do the same wasteful parsing to get the same result. There is no good reason that syntax highlighting shouldn’t be done at build time nor should it require JavaScript.
Looks like MathJax is hosted on a CDN. Everything else, from css to other js files, is hosted alongside the HTML files.
Seems a bit strange. I wonder why they chose to use a CDN for that one js file.
Perhaps because MathJax support is optional? https://rust-lang.github.io/mdBook/format/mathjax.html
Even though the MathJax js file will in turn probably load more things hosted on the CDN. I don’t understand why they are not putting all of the MathJax files alongside the generated HTML files. So that one does not have to rely on any CDN.
Now that I’m at my laptop I can see that you are correct on most things at least now being vendored–though it took me a while to find it since the scripts in the <body> like it’s last decade instead of in the <head> with async or defer attributes.
Maybe it’s because MathJax loading slow would delay rendering, and using a CDN-hosted MathJax increases the chance the content is cached?
That’s usually why people use CDNs. It’s more important for MathJax than, say, interactive scripts, since it can cause rendering.
I don’t think MathJax loads any additional files (I don’t remember seeing any additional network requests).
With first-party isolation being the standard for the last couple of years, there are no “shared caches”. A third-party CDNs might load a particular resource faster, but at the cost of user privacy & reliability. You can know, barring exceptional circumstances, that if your site loaded, it can load its own libraries. Look at the news of Cloudflare, Fastly, et al. going down and the ‘internet breaking’ because there’s been too much centralization and bad advice that all site’s need these sorts of ‘optimizations’.
Interesting enough there seems to be an open PR for that: https://github.com/rust-lang/mdBook/pull/1918