Reducing Bundle Size On React: Part 1
The first of its series in a two-part documentation about reducing the bundle size on React

I work on web
Search for a command to run...
The first of its series in a two-part documentation about reducing the bundle size on React

I work on web
Hey this blog is interesting. Where can I find the Part 2 of this blog? Can anyone please share the link here
Hii Karri Srinivasa Rao, I am still writing the second part of this series, will update you once I am done writing.
OpenClaw is a powerful, self-hosted AI assistant that connects to your tools to perform actions. Explore its Gateway architecture, real-world use cases, and security precautions.

Discover how neo-brutalism is shaping 2026 design trends. See how anti-design principles can create distinct, usable, and memorable product experiences.

When code breaks a pipeline, developers have to stop working and figure out why. This blog shows how an AI agent reads the error, finds the fix, and submits it for review all on its own.

GeekyAnts built a 5-agent fraud detection pipeline that makes decisions in under 200ms — 15x cheaper than single-model systems, with full explainability built in.

A deep dive into how GeekyAnts built a real-time AI fraud detection system that evaluates transactions in milliseconds using a hybrid multi-agent approach.

GeekyAnts Tech Blog
348 posts
GeekyAnts is an AI-powered digital product engineering and consulting company helping startups, enterprises, and Fortune 500 brands build scalable, future-ready digital solutions. Since 2006, we have delivered 800+ successful projects for 550+ global clients across healthcare, BFSI, retail, logistics, education, and enterprise technology. We help businesses accelerate digital transformation through strategy, design, engineering, and AI-led innovation.
Recently while working on a client project, we faced the problem of having to analyze and reduce the bundle size, improve SEO metrics like FCP and LCP, and improve the loading time for the build. The project used Webpacks for configuring npm packages, Babel for jsx and converting es6 javascript to browser-compatible JavaScript. During the run of the project, I was very surprised when I saw the control a developer can have while building a website as it was my first encounter with Webpack and I was blown away by the efficiency with which it happens.

Webpack is a static module bundler which processes your app by starting from the list of modules defined in its configuration file (webpack.config.js). Starting from these entry points, Webpack recursively builds a dependency graph that includes every module your application needs and then proceeds to bundling all of those modules into a small number of bundles - often, only one( bundle[hash].js) - to be loaded by the browser in your index.html file.
But, let us not sway away from the topic! In this article, we will see all about Webpack and in the second instalment of this blog, we will proceed to go in-depth into the topic to explore all the functionalities of this technology.
To follow the instructions in this article, you will require:
Now that we have a slight hint of what we're going to learn, let's start with the basic building block of our application:
React.createElementLet's first go over how we can render jsx on the browser. I'm sure you know how to do this, but let us revise this topic. Here are some observations:
jsx that we write is converted to React.createElement objects.React.createElement will be our building block of choice here since we want to avoid jsx elements(We also have to avoid Babel since it compiees jsx to JavaScript objects)
Here is the diagramatic representation for the React.createElement:

Enter the following code snippet into your console:
//eg.
React.createElement("h1", {}, "Hello World")
Logging the above code on the console would give us the following result:

div, h1, etc.classname.text or any other element.codesandbox:Here is the link for you to experiment with this tech stack.
Note: We are going to use both class-based and functional components since I am assuming that you might be comfortable with either or both of them.
index.htmlYou can use any code editor of your choice, I would recommend vs-code. Enter the following snippet into your console:
<html>
<head>
<title>React Hello World</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"
></script>
<script
src="https://unpkg.com/react@18/umd/react.development.js"
crossorigin
></script>
<script
src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"
crossorigin
></script>
</head>
<style>
.text {
text-align: center;
}
</style>
<body>
<div id="like_button_container"></div>
<div id="homepage"></div>
<script type="module" src="./functionalComp/homepage.js"></script>
<!-- <script type="module" src="./classBasedComp/homepage.js"></script> -->
</body>
</html>
react and react-dom libraries for the react development setup and Bootstrap for CSS (You can remove and provide styles in the style tag option).react and react-dom libraries are required out-of-the-box if we are going to use react-hooks or any React class-based components, react-dom can be the equivalent for the virtual dom (VDOM).CDN for these dependencies, but we could also initialize the repo using npm init and then install these as npm libraries(I would you to try my approach).div element which we will use to create our root for the React app.homepage.js to the script tag as it has an attribute of the type given which is assigned as a module element.It is important that we give the
homepage.jsscript tag an attribute of the module since it tells the compiler that thehomepage.jsis anes-module. This indicates whether we can import or export JavaScript files ases-modulesaccording to our liking, or else it will give us an error message. Read more aboutes-moduleshere
Our homepage that we are going to reference here is a React class-based component. Since I am not using jsx, I will instead use React.createElement to set up the homepage.
import LikeButton from "./like_button.js";
const e = React.createElement;
class HomePage extends React.Component {
constructor(props) {
super(props);
}
render() {
return e(
"div",
{ className: "col-8 m-auto" },
"",
e(LikeButton),
e("h1", { className: "text" }, "react without CRA, babel and webpack"),
e(
"p",
{ className: "text-center" },
" Hello Worlds of React and Webpack!"
),
e("a", { href: "dynamic.html" }, "dynamic"),
e("hr", null),
e("p", { className: "text-right" }, " made with ❤️ by Vivek Lokhande")
);
}
}
const domContainer = document.querySelector("#homepage");
const root = ReactDOM.createRoot(domContainer);
root.render(e(HomePage));
import LikeButton from "./like_button.js";
const e = React.createElement;
function HomePage() {
return e(
"div",
{ className: "col-8 m-auto" },
"",
e(LikeButton),
e("h1", { className: "text" }, "react without CRA, babel and webpack"),
e("p", { className: "text-center" }, " Hello Worlds of React and Webpack!"),
e("a", { href: "dynamic.html" }, "dynamic"),
e("hr", null),
e("p", { className: "text-right" }, " made with ❤️ by Vivek Lokhande")
);
}
const domContainer = document.querySelector("#homepage");
const root = ReactDOM.createRoot(domContainer);
root.render(e(HomePage));
At a first glance, you can notice that:
es-modules import/exports since the homepage.js file is a module.div element.likeButton componentUse the code given below to implement class-based components:
const e = React.createElement;
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = { liked: false };
}
render() {
if (this.state.liked) {
return e("p", {}, "You liked this.");
}
return e(
"button",
{ onClick: () => this.setState({ liked: true }) },
"Like"
);
}
}
export default LikeButton;
Use the code given below to implement functional components:
const e = React.createElement;
function LikeButton() {
const [liked, setLiked] = React.useState(false);
if (liked) {
return e("h5", {}, "You liked this.");
} else {
return e("button", { onClick: () => setLiked((prev) => !prev) }, "Like");
}
}
export default LikeButton;
At first glance, you can notice that:
dynamic.html pageCope-paste the code that is given below for your reference:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
dynamic
</body>
</html>
Now let's look at how everything will function when put together. While working, I have opened the index.html file on my browser. Here's a picture given below for your reference:

Use the following code to pass multiple children to React.createElement:
React.createElement( "div",
{ className: "parent__div" },
React.createElement("h1", { className: "text" }, "react without CRA, babel and webpack"),
React.createElement("p", { className: "text" },"Hello Worlds of React and Webpack!")
)
You can pass as many elements as you want. Using this syntax, you can nest elements to your liking.
build.js file and all files are fetched separately, taking away the scalability factor.jsx, it keeps on getting cumbersome to the eye. create-react-app)react-router here for navigation, but had to give up on the idea in the end because of the complexity involved.React.createElement-1, React.createElement-2, esmodules, common-js modules, React without jsx, Add React to a website