<?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: Muhammad Zakiullah Usman</title>
    <description>The latest articles on DEV Community by Muhammad Zakiullah Usman (@mzakiullahusman).</description>
    <link>https://dev.to/mzakiullahusman</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1194322%2F1d7b3416-d0e6-4c07-b9d8-fcd4614194b7.jpeg</url>
      <title>DEV Community: Muhammad Zakiullah Usman</title>
      <link>https://dev.to/mzakiullahusman</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mzakiullahusman"/>
    <language>en</language>
    <item>
      <title>1 Next.js Import to Rule Them All in Performance</title>
      <dc:creator>Muhammad Zakiullah Usman</dc:creator>
      <pubDate>Tue, 05 Dec 2023 08:08:17 +0000</pubDate>
      <link>https://dev.to/mzakiullahusman/nextjss-one-import-to-rule-them-all-in-performance-pl5</link>
      <guid>https://dev.to/mzakiullahusman/nextjss-one-import-to-rule-them-all-in-performance-pl5</guid>
      <description>&lt;p&gt;I recently read an article that got me interested in optimizing performance in React web applications.&lt;/p&gt;

&lt;p&gt;The article discussed &lt;a href="https://dev.to/mursalfk/reacts-dynamic-trio-code-splitting-unleashed-ig9"&gt;how we can use Dynamic Imports, Lazy and Suspense for code-splitting&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Since I am currently working on a project in Next.js, but I still wanted to implement what I learned as quickly as possible, I looked for how to do the same in Next.js. &lt;/p&gt;

&lt;p&gt;It turned out that its actually much more straightforward in Next. &lt;/p&gt;

&lt;p&gt;In Next.js, you don't need to use React.lazy and Suspense for code splitting, as Next.js handles it automatically through its dynamic imports system.&lt;/p&gt;

&lt;p&gt;So here is the code snippet shamelessly copied directly from the React article:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Lazy, Suspense } from 'react';

const MyComponent = Lazy(() =&amp;gt; import('./MyComponent'));

const App = () =&amp;gt; {
   return (
      &amp;lt;div&amp;gt;
         &amp;lt;h1&amp;gt;My React App&amp;lt;/h1&amp;gt;
         &amp;lt;Suspense fallback={&amp;lt;div&amp;gt;Loading...&amp;lt;/div&amp;gt;}&amp;gt;
            &amp;lt;MyComponent /&amp;gt;
         &amp;lt;/Suspense&amp;gt;
      &amp;lt;/div&amp;gt;
   );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here's the same in Next:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import dynamic from 'next/dynamic';

const MyComponent = dynamic(
  () =&amp;gt; import('./MyComponent'),
  { loading: () =&amp;gt; &amp;lt;p&amp;gt;Loading...&amp;lt;/p&amp;gt; }
);

const App = () =&amp;gt; {
  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;My Next.js App&amp;lt;/h1&amp;gt;
      &amp;lt;MyComponent /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default App;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all that's left is to see how it actually holds up when the e-commerce web application I am working on, going into production! &lt;/p&gt;

&lt;p&gt;I'm sure there are &lt;em&gt;loads&lt;/em&gt;(pun intended) of ways how to bring down your site's loading times. But I can only take the burden of learning one way at a time, and this has helped me, maybe this approach can work out for you. &lt;/p&gt;

&lt;p&gt;As a fairly new MERN stack developer, I never really had to optimize for performance per say. But I still want to make my applications snappy. The quest for self-improvement goes on! &lt;/p&gt;

&lt;p&gt;And there is a long, long way to go.&lt;/p&gt;

&lt;p&gt;Let me know what other methods would you suggest I should learn both for Next and React web applications.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>beginners</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
