So I'm attempting to create my first React application, and when I compile it using webpack, I get a pretty large JS file, because it includes all React, React-DOM, etc.
Is there any way I can use one of the many React CDN's out there and still use
import React from "react";
import ReactDOM from "react-dom";
Thanks in advance!
You need ReactJS CDN to load your React and Components into the ReactJs ecosystem. You need ReactDOM to render your Components in the DOM Tree, and you need Babel to transpile your JSX to simple JS so that all the browsers can read them.
Well, we don't necessarily need webpack to work with React, other alternatives could be Browserify, Parsel, Brunch, etc, but honestly, I don't know how well they fit in with React. js. Webpack is the most widely used and an accepted module bundler and task runner throughout React. js community.
Configuring webpack provides complete control over the development environment, while initializing with Create React App prevents any custom configuration by default.
As is the case with content delivery networks, a React CDN combination reduces the distance between the server and the user to accelerate the delivery of library assets so that webpages would load faster.
You should look at webpack externals feature: https://webpack.js.org/configuration/externals/
This was made for this use case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With