Using node cli vs using CDN
Hello, I was just experiencing a bit with react and I read that I can access react modules either using the cli or using a CDN. I think this always apply to other frameworks.
I was wondering what's the difference here, how does using react using node differs from using a CDN (or any other frameworks)? At the end of the day both import codes, no? Yeah maybe one is faster because we don't need extra http request, is there any other reason what using node for react instead of a CDN can do please. (It's the same thing for tailwind I think, we have a CDN which we can use, don't know if we can use node though)
6 Replies
do you mean node modules?
I think you mean node modules
anyway, using them through the cli means your build process can minify, bundle, and tree-shake your code, and you can reduce the number of http requests which does speed things up. using a CDN for one or two modules on an otherwise static and build-free site can be easier though
there's also some privacy and security concerns. If you download code from a CDN, the CDN has information on your client. You can also not necessarily control the code that's hosted on that CDN as well as you can code hosted on your own system. And you're reliant on the CDN being up for your site to work
for tailwind specifically, the build process massively reduces the size of the code shipped to your client by discarding unused classes in the compiled style sheet
yeah node modules, sorry for late reply
oh ok I see, thanks !
it's difficult to use react/vue or other frameworks CDN, no? For example, I'm learning react, don't think it's possible to have certain file extensions like
.jsx if we use the react CDNI'm not sure tbh
it's not the recommended way to use them for sure
I do know react can work purely in the browser, but no idea how (or why tbh) you would want to do that
yep, will just stich with react with node modules
thanks !!
React can be in js files
The jsx enforcement for component code is your bundler's (vite, webpack) work
Browsers can't recognise jsx files I think
yeah they don't
we need to do some pre-processing first