<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sanket Chaudhari</title>
    <description>The latest articles on DEV Community by Sanket Chaudhari (@sanket1035).</description>
    <link>https://dev.to/sanket1035</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4003414%2Fe415cef4-2aa6-49db-89d2-d632af03bdc6.jpg</url>
      <title>DEV Community: Sanket Chaudhari</title>
      <link>https://dev.to/sanket1035</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sanket1035"/>
    <language>en</language>
    <item>
      <title>How I Split a 450 kB React Entry Bundle into Optimized Chunks with Vite.</title>
      <dc:creator>Sanket Chaudhari</dc:creator>
      <pubDate>Thu, 02 Jul 2026 04:45:36 +0000</pubDate>
      <link>https://dev.to/sanket1035/how-i-split-a-450-kb-react-entry-bundle-into-optimized-chunks-with-vite-221</link>
      <guid>https://dev.to/sanket1035/how-i-split-a-450-kb-react-entry-bundle-into-optimized-chunks-with-vite-221</guid>
      <description>&lt;h1&gt;
  
  
  How I Split a 450 kB React Entry Bundle into Optimized Chunks with Vite
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Lazy Loading • Code Splitting • Performance Optimization&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While building my personal portfolio, I kept adding features such as animations, a floating chatbot, a command palette, a resume viewer, and even a small 2048 game.&lt;/p&gt;

&lt;p&gt;Eventually, I started asking myself one question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How much of my application is actually being downloaded when someone opens my website?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of guessing, I analyzed the production build, visualized the bundle, and optimized it using Vite's manual chunking.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Problem
&lt;/h1&gt;

&lt;p&gt;Every new feature increased the production bundle size.&lt;/p&gt;

&lt;p&gt;The application worked perfectly, but the initial entry bundle had become much larger than I wanted.&lt;/p&gt;

&lt;h2&gt;
  
  
  📷 Screenshot 1
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3vpxnlo90ls6c65fbacx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3vpxnlo90ls6c65fbacx.png" alt=" " width="695" height="764"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1: Production build before optimization.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The build itself wasn't alarming, but it raised an important question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where was all this code coming from?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Simply looking at the bundle size wasn't enough. I wanted to understand which libraries and components were contributing the most to the production build before making any changes.&lt;/p&gt;

&lt;p&gt;Instead of optimizing blindly, I decided to inspect the bundle visually.&lt;/p&gt;




&lt;h1&gt;
  
  
  Understanding the Bundle
&lt;/h1&gt;

&lt;p&gt;To analyze the production output, I used &lt;strong&gt;rollup-plugin-visualizer&lt;/strong&gt;, which generates an interactive treemap of the final bundle.&lt;/p&gt;

&lt;p&gt;The visualization immediately highlighted where most of the JavaScript was coming from.&lt;/p&gt;

&lt;p&gt;Some of the largest contributors were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React &amp;amp; React DOM&lt;/li&gt;
&lt;li&gt;Framer Motion&lt;/li&gt;
&lt;li&gt;Lucide Icons&lt;/li&gt;
&lt;li&gt;My application code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Having this visual breakdown made it much easier to identify what could be separated into dedicated vendor chunks.&lt;/p&gt;

&lt;h2&gt;
  
  
  📷 Screenshot 2
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3b1ixow3ib8cuu1gami4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3b1ixow3ib8cuu1gami4.png" alt=" " width="799" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: Bundle visualization generated using Rollup Plugin Visualizer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;One thing immediately stood out: framework libraries and application code were bundled together more than I wanted.&lt;/p&gt;

&lt;p&gt;Instead of shipping everything through the initial entry bundle, I decided to split the build into smaller, cache-friendly chunks.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Optimization
&lt;/h1&gt;

&lt;p&gt;After identifying the largest dependencies, I reorganized how Vite generated the production build.&lt;/p&gt;

&lt;p&gt;Instead of placing every dependency into a single vendor bundle, I grouped related libraries into dedicated chunks.&lt;/p&gt;

&lt;p&gt;This makes the initial application lighter while allowing browsers to cache framework libraries separately from my own code.&lt;/p&gt;

&lt;p&gt;Here's the &lt;code&gt;manualChunks()&lt;/code&gt; configuration I used:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;manualChunks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node_modules&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-dom&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
      &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-router&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt;
      &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;scheduler&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vendor-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;framer-motion&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vendor-framer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lucide-react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vendor-lucide&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vendor-others&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of one large bundle, the build now generates multiple optimized chunks.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;vendor-react&lt;/strong&gt; → React, React DOM and routing libraries&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;vendor-framer&lt;/strong&gt; → Framer Motion&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;vendor-lucide&lt;/strong&gt; → Lucide Icons&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;vendor-others&lt;/strong&gt; → Remaining third-party dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This structure keeps the application code separate from framework libraries, making future updates and browser caching more efficient.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Results
&lt;/h1&gt;

&lt;p&gt;After applying manual chunking, I generated another production build.&lt;/p&gt;

&lt;p&gt;The difference was immediately visible.&lt;/p&gt;

&lt;h2&gt;
  
  
  📷 Screenshot 3
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fodpsexa3c8qwfi6ailvp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fodpsexa3c8qwfi6ailvp.png" alt=" " width="583" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3: Production build after manual chunking.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Compared with the previous build, the application's entry bundle became significantly smaller while framework libraries were moved into dedicated vendor chunks.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Before&lt;/th&gt;
&lt;th&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Entry Bundle&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;449.65 kB&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;54.72 kB&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modules&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;383&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;353&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build Time&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;596 ms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;383 ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;It's important to note that these numbers refer to the &lt;strong&gt;entry bundle&lt;/strong&gt;, not the total size of every JavaScript asset generated by the build.&lt;/p&gt;

&lt;p&gt;The optimization focused on splitting framework libraries into dedicated chunks, reducing the amount of code required for the initial application load.&lt;/p&gt;




&lt;h1&gt;
  
  
  Lessons Learned
&lt;/h1&gt;

&lt;p&gt;This optimization taught me a few valuable lessons.&lt;/p&gt;

&lt;h3&gt;
  
  
  Measure before optimizing
&lt;/h3&gt;

&lt;p&gt;It's easy to assume what's slowing down an application, but assumptions rarely help. Analyzing the production build and visualizing the bundle showed exactly where optimization efforts should be focused.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bundle visualization removes the guesswork
&lt;/h3&gt;

&lt;p&gt;The treemap made it clear which libraries occupied the most space. Instead of blindly changing configurations, I could make decisions based on actual build output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance is about loading strategy
&lt;/h3&gt;

&lt;p&gt;The objective wasn't simply to reduce file sizes. The real improvement came from reducing the size of the initial entry bundle and separating framework libraries into dedicated vendor chunks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep measuring
&lt;/h3&gt;

&lt;p&gt;Every new dependency affects the production build. I'll continue monitoring bundle size as the portfolio evolves instead of treating optimization as a one-time task.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;This optimization gave me a much better understanding of how modern React applications are bundled and delivered.&lt;/p&gt;

&lt;p&gt;Using Vite's manual chunking, production build analysis, and bundle visualization helped me reorganize the application into a more maintainable and cache-friendly structure.&lt;/p&gt;

&lt;p&gt;There's always more to improve, but this was a valuable step toward building faster, more efficient frontend applications.&lt;/p&gt;




&lt;h1&gt;
  
  
  Tools Used
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Vite&lt;/li&gt;
&lt;li&gt;Rollup Plugin Visualizer&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Vite — &lt;a href="https://vite.dev/" rel="noopener noreferrer"&gt;https://vite.dev/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Rollup Plugin Visualizer — &lt;a href="https://github.com/btd/rollup-plugin-visualizer" rel="noopener noreferrer"&gt;https://github.com/btd/rollup-plugin-visualizer&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Thanks for Reading! 🚀
&lt;/h1&gt;

&lt;p&gt;If you've worked on bundle optimization or React performance, I'd love to hear what techniques worked best for you.&lt;/p&gt;

&lt;p&gt;Feel free to share your thoughts or suggestions in the comments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect With Me
&lt;/h2&gt;

&lt;p&gt;🌐 Portfolio: &lt;a href="https://yourportfolio.com" rel="noopener noreferrer"&gt;https://yourportfolio.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're interested in interactive frontend projects, AI applications, or full-stack development, feel free to explore my work.&lt;/p&gt;

&lt;p&gt;💻 GitHub: &lt;a href="https://github.com/sanket1035" rel="noopener noreferrer"&gt;https://github.com/sanket1035&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💼 LinkedIn: &lt;a href="https://linkedin.com/in/sanketchaudhari1035" rel="noopener noreferrer"&gt;https://linkedin.com/in/sanketchaudhari1035&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>vite</category>
      <category>webdev</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
