3 ms·
That's basically the purpose of public CDN-hosted JavaScript, like cdnjs [1] and what most major JS libraries do [2]. However, I think this is becoming less co
by tlrobinson 11y ago
That's basically the purpose of public CDN-hosted JavaScript, like cdnjs [1] and what most major JS libraries do [2].
However, I think this is becoming less common with the increasing popularity of module bundlers like webpack. It's still possible with webpack [3], but it's not as easy as a 'npm i react' and 'import React from "react";'.
That said, a module bundler could easily automatically swap out local modules for modules hosted on CDNs in production builds (with fallbacks in case the CDN is down). I'm a little surprised this doesn't seem to exist yet, at least for webpack.
1. https://cdnjs.com/ https://cdnjs.com/
2. https://code.jquery.com/ https://code.jquery.com/
3. https://webpack.github.io/docs/library-and-externals.html https://webpack.github.io/docs/library-and-externals.html
- lisivka 11y agoI mean, we need <library> tag in addition to <script> tag, which we already have. e.g. <library name="react" version="^5.0"><script src="https://cdn/react-5.0.8.js"></script></library> https://cdn/react-5.0.8.js"></script></library>