<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ web - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ web - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 22 Jun 2026 23:18:43 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/web/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Optimize Next.js Web Apps for Better Performance ]]>
                </title>
                <description>
                    <![CDATA[ As engineers, we often get so carried away with other aspects of development that we overlook how users perceive and interact with our applications. This oversight can result in users leaving the app almost as soon as they arrive, leading to higher b... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/optimize-nextjs-web-apps-for-better-performance/</link>
                <guid isPermaLink="false">6776a323218b455d646035b2</guid>
                
                    <category>
                        <![CDATA[ Next.js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web performance ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Performance Optimization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ React ]]>
                    </category>
                
                    <category>
                        <![CDATA[ optimization ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ayantunji Timilehin ]]>
                </dc:creator>
                <pubDate>Thu, 02 Jan 2025 14:30:59 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1735828217839/b65374be-d891-4f19-a359-f84f2ac8f3b9.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>As engineers, we often get so carried away with other aspects of development that we overlook how users perceive and interact with our applications. This oversight can result in users leaving the app almost as soon as they arrive, leading to higher bounce rates and minimal engagement.</p>
<p>At its core, every business thrives on delivering value to its users. When users are unable to access this value due to poor performance, it ultimately impacts the business's success. Slow load times, among other factors, frustrate users and drive them away before they even get a chance to engage.</p>
<p>Optimizing performance is more than just a technical detail – it’s also a critical part of creating a successful application. Without it, even the best features can go unnoticed if users don’t stick around long enough to see them.</p>
<p>In this article, we’ll explore key approaches to optimize your Next.js application, making it faster and more efficient.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-building-a-performant-app">Building a Performant Application</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-optimize-your-applications">How to Optimize Your Applications</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-key-techniques-to-optimize-performance">Key Techniques To Optimize Performance</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-1-using-the-nextjs-image-component">Using The Next.js Image Component</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-2-optimizing-third-party-scripts-with-the-nextjs-script-component">Optimizing Third-Party Scripts with the Next.js Script Component</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-3-remove-unused-packagesdependencies">Remove Unused Packages/Dependencies</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-4-caching-and-incremental-static-regeneration-isr">Caching and Incremental Static Regeneration (ISR)</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-caching-frequently-used-content">Caching Frequently Used Content</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-5-font-optimization-with-nextfont">Font Optimization With next/font</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-6-lazy-loading-and-code-splitting">Lazy Loading And Code Splitting</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-lazy-loading-in-nextjs">Lazy Loading in Next.js</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-code-splitting">Code Splitting</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-building-a-performant-application">Building a Performant Application</h2>
<p>Making your apps more performant means striking the right balance between speed, responsiveness, and efficient use of resources. You should strive to create an application that delivers value and keeps users satisfied.</p>
<p>Building a performant app is about making sure the app feels smooth and intuitive so that there are no frustrating lags when a user clicks buttons, scrolls, or navigates around. You’ll also want to make sure that data loads or updates without unnecessary delays.</p>
<h2 id="heading-how-to-optimize-your-applications">How to Optimize Your Applications</h2>
<p>The first step in optimizing your application is identifying problem areas. A number of tools and packages can help you analyze your application's performance effectively. Here's how you can use them:</p>
<h3 id="heading-using-npm-run-build">Using <code>npm run build</code></h3>
<p>When you run <code>npm run build</code>, Next.js creates a production-ready version of your application and gives a detailed breakdown of your pages. This includes:</p>
<ul>
<li><p><strong>Size</strong>: The size of the JavaScript files for each route. Highlighting any routes that are too large and could slow things down. Smaller page sizes generally result in faster load times while large pages might take longer to download, especially for users with slower network connections.</p>
</li>
<li><p><strong>First Load Js</strong>: This column provides information about the total amount of JavaScript the browser needs to download and execute to fully render the page for the first time. Large <strong>First Load JS</strong> values</p>
<p>  cause Slower Time-to-Interactive (TTI).</p>
</li>
</ul>
<p>Running this command produces an analysis like below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734639730677/cfd1f858-a9df-4e6c-af28-454857309156.png" alt="Example result of running npm run build" class="image--center mx-auto" width="984" height="300" loading="lazy"></p>
<h3 id="heading-using-nextbundle-analyzer">Using <code>@next/bundle-analyzer</code></h3>
<p>The <a target="_blank" href="https://www.npmjs.com/package/@next/bundle-analyzer">bundle analyzer</a> is a package provided by Next.js to analyze the size of JavaScript bundles by providing a visual representation of the application’s module and dependencies. Here’s how to use the package:</p>
<p>First, install the package by running this command:</p>
<pre><code class="lang-bash">npm install @next/bundle-analyzer
</code></pre>
<p>Or you can use yarn:</p>
<pre><code class="lang-bash">yarn add @next/bundle-analyzer
</code></pre>
<p>Then add the <code>@next/bundle-analyzer</code> configuration to your <code>next.config.js</code> file:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> withBundleAnalyzer = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@next/bundle-analyzer'</span>)({
  <span class="hljs-attr">enabled</span>: process.env.ANALYZE === <span class="hljs-string">'true'</span>,
});

<span class="hljs-built_in">module</span>.exports = withBundleAnalyzer({
  <span class="hljs-comment">// other Next.js config options here</span>
});
</code></pre>
<p>To analyze your application bundles while generating a production build, run the following command:</p>
<pre><code class="lang-bash">ANALYZE=<span class="hljs-literal">true</span> npm run build
</code></pre>
<p>For a step-by-step guide on how to use the bundle analyzer effectively, check out this detailed <a target="_blank" href="https://www.youtube.com/watch?v=EIGmcxwbbZw">video tutorial</a></p>
<h3 id="heading-browser-tools">Browser tools</h3>
<p>Finally, modern browsers, including Google Chrome, Firefox, and Edge, offer powerful tools to analyze and improve your application's performance. Features like the Performance Tab help you record and visualize how your application runs, pinpointing issues like slow rendering or long tasks.</p>
<p>You can also use tools like Lighthouse (available in Chrome and Edge) to generate automated audits, highlighting problems such as large assets and unoptimized resources.</p>
<p>To access the <strong>Lighthouse</strong> and <strong>Performance</strong> tabs:</p>
<ol>
<li><p>Open your browser's developer tools by right-clicking anywhere on the browser and selecting the <strong>Inspect</strong> option or pressing <strong>Command + Option + I</strong> (on Mac) or <strong>Ctrl + Shift + I</strong> (on Windows).</p>
</li>
<li><p>Look at the top menu in the developer tools.</p>
</li>
<li><p>If you don’t see the <strong>Lighthouse</strong> or <strong>Performance</strong> tabs right away, click the <strong>double right arrow (&gt;&gt;)</strong> to reveal hidden tabs.</p>
</li>
<li><p>Select the desired tab to start analyzing performance or generating a Lighthouse report.</p>
</li>
</ol>
<p>Here is an example of a generated audit in the Performance tab on Chrome</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735616911745/e5f09934-df99-40fc-b194-a292a21a4517.png" alt="image of the performance tab on chrome browser" class="image--center mx-auto" width="1130" height="966" loading="lazy"></p>
<p>Here’s another image showing the generated audit by lighthouse</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1735617075187/dfde608b-eeb7-443d-81c6-56ff2a6dd92b.png" alt="dfde608b-eeb7-443d-81c6-56ff2a6dd92b" class="image--center mx-auto" width="1124" height="1522" loading="lazy"></p>
<h2 id="heading-key-techniques-to-optimize-performance">Key Techniques to Optimize Performance</h2>
<h3 id="heading-1-using-the-nextjs-image-component">1.) Using The Next.js <code>Image</code> Component</h3>
<p>Images often account for the largest portion of page weight, directly affecting load times and user experience. Large images slow down rendering and ultimately, increase bandwidth usage.</p>
<p>Next.js has a built-in <code>Image</code> component that automatically optimizes images, making it very useful for web performance. It takes care of resizing, lazy loading, and format optimization, so images are served in the most performant format (like .WebP) when the browser supports it.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> Image <span class="hljs-keyword">from</span> <span class="hljs-string">'next/image'</span>;

    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">Image</span>
      <span class="hljs-attr">src</span>=<span class="hljs-string">"/house.jpg"</span>
      <span class="hljs-attr">alt</span>=<span class="hljs-string">"House Image"</span>
      <span class="hljs-attr">width</span>=<span class="hljs-string">{700}</span>
      <span class="hljs-attr">height</span>=<span class="hljs-string">{500}</span>
      <span class="hljs-attr">priority</span>=<span class="hljs-string">{false}</span> // <span class="hljs-attr">Lazy</span> <span class="hljs-attr">loads</span> <span class="hljs-attr">the</span> <span class="hljs-attr">image</span> <span class="hljs-attr">by</span> <span class="hljs-attr">default</span>
    /&gt;</span></span>
</code></pre>
<p>In the snippet above,</p>
<ul>
<li><p><code>src="/house.jpg"</code>: This points to the image file's location, which is in the <code>public</code> folder. Images in the <code>/public</code> directory are served statically, so you don’t need extra configuration.</p>
</li>
<li><p><code>alt="House Image"</code>: The <code>alt</code> text (just like in the native HTML <code>image</code> element) provides a description of the image, which is great for accessibility (like screen readers) and also helps with SEO.</p>
</li>
<li><p><code>width &amp; heigh</code>t: By explicitly setting the width and height, Next.js can calculate the space the image will occupy on the page before it loads. This prevents the page layout from shifting as the image loads, which improves user experience and boosts performance metrics like <a target="_blank" href="https://blog.hubspot.com/marketing/cumulative-layout-shift">Cumulative Layout Shift</a> (as shown in the image above).</p>
</li>
<li><p><code>priority={false}</code>: This ensures the image will only load when it's near the user's viewport conserving the bandwidth and improving page load times for non-critical images. However, for important images that should load immediately (like those visible as soon as the page opens), you can set <code>priority={true}</code> to bypass lazy loading and ensure the image loads as quickly as possible.</p>
</li>
</ul>
<p>One of the key advantages of the Next.js <code>Image</code> component is its built-in <strong>lazy loading</strong> feature. This means that images won’t be loaded until they are actually needed (when they enter the viewport). By only loading images that are about to be viewed, performance is improved and pages can load faster, even with many high-quality images.</p>
<h3 id="heading-2-optimizing-third-party-scripts-with-the-nextjs-script-component">2.) Optimizing Third-Party Scripts with the Next.js Script Component</h3>
<p>Third-party scripts, such as analytics tools or advertising networks, can heavily affect your application's performance if not properly managed. Next.js has a <strong>Script</strong> component that makes it easy to load scripts efficiently, giving you control over how and when they load.</p>
<p>The <code>Script</code> component allows you to define a <strong>loading strategy</strong> for scripts, determining when and how they are fetched and executed. By prioritizing or deferring scripts based on their importance, you can improve the overall performance and user experience of your application.</p>
<ul>
<li><p><code>beforeInteractive</code><strong>:</strong> Use this strategy for scripts that must load before the page becomes interactive, like essential analytics or monitoring tools.</p>
</li>
<li><p><code>afterInteractive</code>: When you use this strategy, the script loads after the page becomes interactive, which is the default behavior. This is ideal for scripts that add functionality but aren’t essential for initial rendering.</p>
</li>
<li><p><code>lazyOnload</code>: Defers loading the script until all other page resources have finished loading. This is perfect for non-essential scripts like ads or social media widgets.</p>
</li>
</ul>
<pre><code class="lang-javascript">&lt;Script src=<span class="hljs-string">"https://example.com/non-essential.js"</span> strategy=<span class="hljs-string">"lazyOnload"</span> /&gt; <span class="hljs-comment">//Pass the strategy as a prop to the component</span>
</code></pre>
<p>By leveraging the Next.js <code>Script</code> component, you can prevent scripts from blocking critical rendering, reducing load times and improve <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Time_to_interactive">Time to Interactive</a> (TTI).</p>
<h3 id="heading-3-remove-unused-packagesdependencies">3.) Remove Unused Packages/Dependencies</h3>
<p>Over time, as you build and maintain your project, unused dependencies can pile up in your codebase. These unnecessary packages increase the size of your project, slow down installation times, and make the code harder to maintain. Cleaning up these unused dependencies is essential for optimizing your application's performance and keeping your codebase clean.</p>
<p>The <a target="_blank" href="https://www.npmjs.com/package/depcheck">depcheck</a> tool is a great way to identify and remove unused dependencies from your project. It analyzes your <code>package.json</code> and the project files to find unused dependencies, unused devDependencies, and missing dependencies.</p>
<p>You can run a <code>depcheck</code> like this:</p>
<pre><code class="lang-bash">npx depcheck
</code></pre>
<p>After identifying the unused dependencies, you can remove them by running:</p>
<pre><code class="lang-bash">npm uninstall &lt;package-name&gt;
</code></pre>
<p>or with yarn:</p>
<pre><code class="lang-bash">yarn remove &lt;package-name&gt;
</code></pre>
<p>Regularly running <code>depcheck</code> is a simple yet effective way to keep your project clean and efficient.</p>
<h3 id="heading-4-caching-and-incremental-static-regeneration-isr">4.) Caching and Incremental Static Regeneration (ISR)</h3>
<p>When you find yourself running the same calculations or database queries repeatedly, you should consider caching. It’s a simple yet powerful way to boost your web application's performance, especially for content that doesn’t change often. By storing frequently accessed data in a cache, you can avoid unnecessary processing and speed up load times.</p>
<p>In Next.js, you can take this a step further with Incremental Static Regeneration (ISR), which lets you serve static content instantly while keeping it fresh behind the scenes.</p>
<p><strong>Incremental Static Regeneration (ISR)</strong> in Next.js lets you update static pages without rebuilding the whole site. Here's how it works:</p>
<ol>
<li><p><strong>Build time generation</strong>: ISR generates pages when the site is built.</p>
</li>
<li><p><strong>Caching</strong>: It stores the pages so they load quickly when users visit.</p>
</li>
<li><p><strong>Background updates</strong>: When content changes, ISR updates the pages behind the scenes without affecting users.</p>
</li>
<li><p><strong>Dynamic updates</strong>: It combines the fast loading of static pages with the ability to update content regularly.</p>
</li>
</ol>
<pre><code class="lang-javascript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getStaticProps</span>(<span class="hljs-params"></span>) </span>{

  <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> fetchData();

  <span class="hljs-keyword">return</span> {
    <span class="hljs-attr">props</span>: { data },
    <span class="hljs-comment">//regenerate the page every 20 seconds.</span>
    <span class="hljs-attr">revalidate</span>: <span class="hljs-number">20</span>,
  };
}

<span class="hljs-comment">//pre-render the page as static content</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">MyPage</span>(<span class="hljs-params">{ data }</span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>My Page<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>{data}<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> MyPage;
</code></pre>
<h3 id="heading-caching-frequently-used-content">Caching Frequently Used Content</h3>
<p>For websites with pages that get a lot of visitors, like product listings or blog posts, it's important to keep the content fast and up-to-date.</p>
<p>Caching helps achieve this by saving a copy of the page so it doesn't need to be created from scratch each time someone visits. The browser or server will store this cached page for a set amount of time, which is controlled by caching headers. Meanwhile, ISR (Incremental Static Regeneration) ensures that the page can be updated in the background when necessary, without needing to rebuild the entire site.</p>
<p>In applications with lots of data, caching can also speed up the process by storing API responses. This way, when users request the same data again, they can get it quickly from the cache instead of waiting for it to be fetched anew. Tools like Vercel and Content Delivery Networks (CDNs) help by storing these cached pages in multiple locations around the world, so visitors can access them faster.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">export</span> <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getStaticProps</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> fetchData();

  <span class="hljs-keyword">return</span> {
    <span class="hljs-attr">props</span>: { data },
    <span class="hljs-comment">// Regenerate page at most once every 30 seconds</span>
    <span class="hljs-attr">revalidate</span>: <span class="hljs-number">30</span>,
    <span class="hljs-comment">// Cache for 1 hour at the CDN level</span>
    <span class="hljs-attr">headers</span>: {
      <span class="hljs-string">'Cache-Control'</span>: <span class="hljs-string">'public, max-age=3600, must-revalidate'</span>,
    },
  };
}
</code></pre>
<p>Here, the page regenerates every 30 seconds and is cached at the CDN level for one hour. The <code>Cache-Control</code> header tells the CDN and browser to cache the page for 1 hour and revalidate it afterward.</p>
<p>For a deeper dive into caching and its role in web performance, check out this insightful <a target="_blank" href="https://www.freecodecamp.org/news/caching-vs-content-delivery-network/">freeCodeCamp article on Caching vs. Content Delivery Networks</a>.</p>
<h3 id="heading-5-font-optimization-with-nextfont">5.) Font Optimization With <code>next/font</code></h3>
<p>The <code>next/font</code> module in Next.js automatically handles font loading for improved performance, so you don’t need to manually configure or use extra libraries. It loads only the essential parts of the font, which results in faster page load times.</p>
<p>To further reduce the font file size, you can provide the <code>subsets</code> array which ensures fewer bytes are transferred and pages load quickly.</p>
<p>Here’s how it works:</p>
<ul>
<li><p><strong>Automatic font loading</strong>: The module optimizes font loading automatically, making sure fonts are served in the most efficient way, improving performance without extra effort.</p>
</li>
<li><p><strong>Subsetting fonts</strong>: You can specify the exact font characters needed for your app.</p>
</li>
<li><p><strong>Font display strategy</strong>: The font-display strategy determines how text is shown to the user while fonts are loading. Next.js typically uses the <code>swap</code> strategy by default, but you can manually configure it if necessary. The most common strategies are <code>swap</code> <code>fallback</code> <code>optional</code> and <code>block</code>.</p>
</li>
<li><pre><code class="lang-javascript">  <span class="hljs-keyword">import</span> { Inter } <span class="hljs-keyword">from</span> <span class="hljs-string">'next/font/google'</span>

  <span class="hljs-keyword">const</span> inter = Inter({
    <span class="hljs-attr">subsets</span>: [<span class="hljs-string">'latin'</span>, <span class="hljs-string">'latin-ext'</span>], <span class="hljs-comment">// Load only the Latin and extended Latin subsets</span>
    <span class="hljs-attr">weight</span>: <span class="hljs-string">'400'</span>, <span class="hljs-comment">// Choose the specific weight you need</span>
    <span class="hljs-attr">style</span>: <span class="hljs-string">'normal'</span>, <span class="hljs-comment">// Specify the style if needed</span>
  })

  <span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Page</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">{inter.className}</span>&gt;</span>Hello World<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  }
</code></pre>
</li>
</ul>
<p>The snippet above uses the Next.js built-in tool for Google Fonts. Instead of adding the font link in your HTML or using a third-party library, you can import it directly like this for ease and efficiency.s</p>
<ul>
<li><p><strong>subsets:</strong> Tells the app to load only the characters needed. Skipping other character sets like Cyrillic (used in Russian) or Greek, avoids downloading extra, unnecessary data, which keeps your app lightweight and faster to load.</p>
</li>
<li><p><strong>weight:</strong> Instead of loading all font weights (e.g., Bold, Light), you only bring in Regular (400). This reduces the overall size.</p>
</li>
<li><p><strong>style:</strong> Stick with the standard style (no fancy italics). This also trims down what’s downloaded.</p>
</li>
</ul>
<h3 id="heading-6-lazy-loading-and-code-splitting">6.) Lazy Loading and Code Splitting</h3>
<p>When building web apps, you want to make sure your users don’t wait too long for your pages to load. A big part of this involves reducing how much JavaScript is loaded when the page first opens. Two techniques that help with this are <strong>lazy loading</strong> and <strong>code splitting</strong>, both of which Next.js makes easy to use.</p>
<h4 id="heading-lazy-loading-in-nextjs">Lazy Loading in Next.js</h4>
<p>Think of lazy loading like waiting to download a movie only when you decide to watch it. Imagine you have a large component like a chart or a map that users only see after interacting with a page. Instead of loading it upfront, you can tell Next.js to load it only when it’s needed using <code>next/dynamic</code>.</p>
<h4 id="heading-code-splitting-in-nextjs">Code Splitting in Next.js</h4>
<p>Code splitting breaks your JavaScript into smaller pieces (called bundles), so users only load what’s necessary. For example, if a user visits your homepage, there’s no need to load JavaScript for other pages like "About Us" or "Dashboard". It typically happens during the build process or dynamically at runtime.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> dynamic <span class="hljs-keyword">from</span> <span class="hljs-string">'next/dynamic'</span>

<span class="hljs-comment">// Load HeavyComponent only when it’s rendered</span>
<span class="hljs-keyword">const</span> HeavyComponent = dynamic(<span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">import</span>(<span class="hljs-string">'./HeavyComponent'</span>), { <span class="hljs-attr">ssr</span>: <span class="hljs-literal">false</span> })

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Home</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome Home!<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">HeavyComponent</span> /&gt;</span> {/* This loads only when rendered */}
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  )
}
</code></pre>
<p>In the above code, <code>dynamic</code> dynamically imports the component only when needed. <code>ssr: false</code> disables server-side rendering for the component, which can save resources if the component doesn’t need to be pre-rendered.</p>
<p>Next.js automatically splits code by page, meaning each page only loads the necessary JavaScript when accessed, improving load times. For more granular control, <code>next/dynamic</code> allows you to dynamically import specific components, ensuring they are loaded lazily only when needed. While Next.js handles page-level code splitting by default, using <code>next/dynamic</code> gives you the flexibility to apply component-level splitting, optimizing resource loading and enhancing performance.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Creating a high-performance application is a very important aspect of any business. A faster and more efficient application enhances user engagement, lowers bounce rates, and boosts SEO rankings, which all contribute to business growth and customer satisfaction.</p>
<p>By utilizing these techniques we discussed in this guide, you can provide a smooth user experience while maintaining optimal efficiency behind the scenes.</p>
<p>Remember, every second saved in load time translates to happier users and, ultimately, better business outcomes.</p>
<p>Thank you for reading!</p>
<p>Want to connect with me?</p>
<ul>
<li><p>Twitter / X: <a target="_blank" href="https://x.com/Timi471">@timi471</a></p>
</li>
<li><p>Linkedin: <a target="_blank" href="https://www.linkedin.com/in/timilehin-micheal/">Ayantunji Timilehin</a></p>
</li>
<li><p>Email: ayantunjitimilehin@gmail.com</p>
</li>
</ul>
<h3 id="heading-references">References</h3>
<ul>
<li><p><a target="_blank" href="https://nextjs.org/docs/pages/building-your-application/optimizing">Next.Js Documentation</a></p>
</li>
<li><p><a target="_blank" href="https://www.freecodecamp.org/news/caching-vs-content-delivery-network/">Caching-vs-content-delivery-network</a></p>
</li>
<li><p><a target="_blank" href="https://www.youtube.com/watch?v=EIGmcxwbbZw">Using next/bundle-analyzer</a></p>
</li>
<li><p><a target="_blank" href="https://blog.hubspot.com/marketing/cumulative-layout-shift">Cumulative layout shift</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is HTTP? Protocol Overview for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ Without HTTP (Hypertext Transfer Protocol), the World Wide Web as we know it today would not exist. HTTP is the protocol that enables the transfer of data over the internet, allowing users to access websites and other online resources.   There are va... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-http/</link>
                <guid isPermaLink="false">66c17cd08c83c36e8b078726</guid>
                
                    <category>
                        <![CDATA[ http ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Rufai Mustapha ]]>
                </dc:creator>
                <pubDate>Thu, 06 Apr 2023 16:53:26 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/04/http--5-.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Without HTTP (Hypertext Transfer Protocol), the World Wide Web as we know it today would not exist. HTTP is the protocol that enables the transfer of data over the internet, allowing users to access websites and other online resources.  </p>
<p>There are various ways to design web applications, including GraphQL, SOAP, Falcor, gRPC, WebSockets, and Serverless Functions, with REST being the most popular (according to the <a target="_blank" href="https://www.postman.com/state-of-api/2021/">2021 State-of-API</a> survey by Postman). And at the heart of all these architectures is HTTP.</p>
<h2 id="heading-what-to-learn-along-with-http">What to Learn Along with HTTP</h2>
<p>To understand HTTP, it is helpful to have a basic understanding of the following concepts:</p>
<ol>
<li>Networking: Knowledge of how computers communicate with each other over networks is essential for understanding HTTP. This includes concepts such as IP addresses, DNS, and routing.</li>
<li>Web architecture: HTTP is a key part of web architecture, so understanding how web applications and websites are built can help you understand HTTP better. This includes concepts such as HTML, CSS, and JavaScript.</li>
<li>Server-side programming: HTTP is used to communicate between web browsers and servers, so understanding how servers work and how to build server-side applications can help you understand how HTTP works.</li>
<li>Client-side programming: HTTP is also used to communicate between web browsers and client-side applications, so understanding how to build client-side applications using JavaScript can also be helpful.</li>
</ol>
<h3 id="heading-what-to-expect-in-this-article">What to Expect in This Article</h3>
<ul>
<li>How the HTTP protocol works.</li>
<li>How to make network requests with Chrome and Postman.</li>
<li>How to upload data with the HTTP POST method in Postman.</li>
</ul>
<p>By the end of the article, readers should have a basic understanding of HTTP, as well as the tools and resources available for testing and troubleshooting applications.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><a class="post-section-overview" href="#heading-introduction-to-http">Introduction to HTTP</a></li>
<li><a class="post-section-overview" href="#heading-what-is-the-http-request-response-cycle">What is the HTTP Request-Response Cycle?</a></li>
<li><a class="post-section-overview" href="#heading-how-to-create-http-requests">How to Create HTTP Requests</a></li>
<li><a class="post-section-overview" href="#heading-what-is-an-http-request-url">What is an HTTP Request URL?</a></li>
<li><a class="post-section-overview" href="#heading-what-are-http-request-methods">What Are HTTP Request Methods?</a></li>
<li><a class="post-section-overview" href="#heading-what-are-http-request-headers">What Are HTTP Request Headers?</a></li>
<li><a class="post-section-overview" href="#heading-what-is-an-http-request-body">What is an HTTP Request Body?</a></li>
<li><a class="post-section-overview" href="#heading-what-is-an-http-response">What is an HTTP Response?</a></li>
</ul>
<h2 id="heading-introduction-to-http">Introduction to HTTP</h2>
<p>HTTP (Hypertext Transfer Protocol) is a protocol used for exchanging information over the internet. HTTP is like the delivery system for information on the internet. It makes sure information goes from one place to another, like how ships carry goods across the ocean. It's the foundation of the World Wide Web.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/04/http-client-server.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>HTTP is what makes the internet work. It's a way for web browsers and servers to talk to each other and send things like web pages back and forth. It's important for people who build websites and web applications to know how it works.  </p>
<p>Without HTTP, it would be difficult to imagine how the internet would work. There would be no web pages, no URLs, and no hyperlinks. Instead, users would need to know the exact IP address of the server hosting the information they want to access, and they would need to use a low-level protocol like TCP/IP to transfer data.</p>
<h2 id="heading-what-is-the-http-request-response-cycle">What is the HTTP Request-Response Cycle?</h2>
<p>Communication in HTTP centers around a concept called the Request-Response Cycle. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/04/http-client-server-RR.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The request-response cycle is the process by which a client (such as a web browser or a mobile app) communicates with a server to retrieve resources or perform actions. The cycle involves several steps:</p>
<ol>
<li>The client initiates a request to the server by sending an HTTP request message, which contains information such as the requested resource and any additional parameters.</li>
<li>The server receives the request message and processes it, using its resources to generate a response message.</li>
<li>The server sends the response message back to the client, which typically contains the requested resource (such as a web page) and any additional information or metadata.</li>
<li>The client receives the response message and processes it, usually by rendering the content in a web browser or displaying it in an app.</li>
<li>The client may initiate additional requests to the server, repeating the cycle as needed.</li>
</ol>
<h2 id="heading-how-to-create-http-requests">How to Create HTTP Requests</h2>
<p>To create a valid HTTP request, you need the following:</p>
<ul>
<li>A URL.</li>
<li>The HTTP method.</li>
<li>A list of headers (request headers).</li>
<li>The request body.</li>
</ul>
<p>Here's an example of an HTTP request header, with three lines:</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/watch?v=8PoQpnlBXD0</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: www.youtube.com
<span class="hljs-attribute">Cookie</span>: GPS=1; VISITOR_INFO1_LIVE=kOe2UTUyPmw; YSC=Jt6s9YVWMd4
</code></pre>
<ol>
<li>The first line specifies the HTTP method, path, and protocol version. In this case, it is a <code>GET</code> request for the video located at the path <code>/watch?v=8PoQpnlBXD0</code> using the HTTP/1.1 protocol.</li>
<li>The second line specifies the host of the website, which is <a target="_blank" href="http://www.youtube.com/"><code>www.youtube.com</code></a>.</li>
<li>The third line contains a cookie header, which is used for sending and storing small pieces of data on the client side. In this case, the cookie header contains three values: <code>GPS=1, VISITOR_INFO1_LIVE=kOe2UTUyPmw</code>, and <code>YSC=Jt6s9YVWMd4</code>. These values can be used by YouTube to track and personalize the user's experience.</li>
</ol>
<h2 id="heading-what-is-an-http-request-url">What is an HTTP Request URL?</h2>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/04/url.jpg" alt="Image" width="600" height="400" loading="lazy"></p>
<p>When a web browser attempts to access an image on the internet, it sends a request to the server using a URL. This URL is <em>unique</em> and points to a specific <em>resource</em> on the server.  </p>
<p>A resource can be anything that has a name and can be accessed with a unique identifier like a user, product, article, document, or image. You can think of resources as <em>nouns</em>.</p>
<h2 id="heading-what-are-http-request-methods">What Are HTTP Request Methods?</h2>
<p>The request method tells the server what kind of action the client wants the server to take. The most common methods are:</p>
<table>
<thead>
<tr>
<th>HTTP Methods</th>
<th>Definition</th>
</tr>
</thead>
<tbody>
<tr>
<td>HEAD</td>
<td>Asks the server for status (size, availability)  of a resource.</td>
</tr>
<tr>
<td>GET</td>
<td>Asks the server to retrieve a resource.</td>
</tr>
<tr>
<td>POST</td>
<td>Asks the server to create a new resource.</td>
</tr>
<tr>
<td>PUT</td>
<td>Asks the server to edit/update an existing resource.</td>
</tr>
<tr>
<td>DELETE</td>
<td>Asks the server to delete a resource.</td>
</tr>
</tbody>
</table>

<h2 id="heading-what-are-http-request-headers">What Are HTTP Request Headers?</h2>
<p>HTTP request headers are additional pieces of information that are sent by the client as part of an HTTP request. They have a name/value format. That is:</p>
<pre><code class="lang-txt">Name: Value
</code></pre>
<p>These headers provide context and additional instructions to the server, which can be used to process the request or customize the response.</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/hqQR1O2H_ck" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>Here's an example of an HTTP request header:</p>
<pre><code class="lang-http"><span class="hljs-keyword">GET</span> <span class="hljs-string">/api/data</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: example.com
<span class="hljs-attribute">User-Agent</span>: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
<span class="hljs-attribute">Accept</span>: application/json
<span class="hljs-attribute">Accept-Language</span>: en-US,en;q=0.5
<span class="hljs-attribute">Authorization</span>: Token abc123
<span class="hljs-attribute">Cache-Control</span>: no-cache
<span class="hljs-attribute">Connection</span>: keep-alive
<span class="hljs-attribute">Referer</span>: https://www.google.com/
<span class="hljs-attribute">Pragma</span>: no-cache
</code></pre>
<p>In this example, the <code>GET</code> method is used to send a request to the <code>/api/data</code> endpoint on the <code>example.com</code> server using HTTP/1.1 protocol. The request includes ten headers:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Headers</td><td>Definition</td></tr>
</thead>
<tbody>
<tr>
<td>Host</td><td>This header specifies the hostname of the server that the client is trying to connect to.</td></tr>
<tr>
<td>User-Agent</td><td>This header provides information about the client that is making the request (in this case, a version of the Chrome browser).</td></tr>
<tr>
<td>Accept</td><td>This header specifies the MIME types of data that the client is willing to accept in the response.</td></tr>
<tr>
<td>Accept-Language</td><td>This header specifies the preferred language(s) for the response.</td></tr>
<tr>
<td>Authorization</td><td>This header provides an access token (in this case, Token abc123) for authentication purposes.</td></tr>
<tr>
<td>Cache-Control</td><td>This header specifies caching directives for both requests and responses.</td></tr>
<tr>
<td>Connection</td><td>This header specifies options for the connection handling between client and server.</td></tr>
<tr>
<td>Referer</td><td>This header specifies the URL of the page that linked to the current page.</td></tr>
<tr>
<td>Pragma</td><td>This header specifies implementation-specific directives that might apply to any agent along the request-response chain.</td></tr>
<tr>
<td>Content-Type</td><td>This header specifies the MIME type of the data that is being sent in the body of the request, but it is not used in this example because this is a GET request without a request body.</td></tr>
</tbody>
</table>
</div><div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/Pjok-1Q6MOs" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-what-is-an-http-request-body">What is an HTTP Request Body?</h2>
<p>In HTTP, the request body is the data that is sent from the client to the server as part of an HTTP request. The example below shows how to upload an image to the <a target="_blank" href="https://documenter.getpostman.com/view/5578104/RWgqUxxh#5a07d324-155b-487e-80a5-b1b9c1775339">Cat API Server</a>:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/zAVCD0nLnjg" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>And here's what the request looks like:</p>
<pre><code class="lang-http"><span class="hljs-keyword">POST</span> <span class="hljs-string">/v1/images/upload</span> HTTP/1.1
<span class="hljs-attribute">Host</span>: api.thecatapi.com
<span class="hljs-attribute">x-api-key</span>: API_KEY
<span class="hljs-attribute">Content-Length</span>: 232
<span class="hljs-attribute">Content-Type</span>: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

<span class="solidity"><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>WebKitFormBoundary7MA4YWxkTrZu0gW
Content<span class="hljs-operator">-</span>Disposition: form<span class="hljs-operator">-</span>data; name<span class="hljs-operator">=</span><span class="hljs-string">"file"</span>; filename<span class="hljs-operator">=</span><span class="hljs-string">"/C:/Users/USER/Downloads/cat1.jpg"</span>
Content<span class="hljs-operator">-</span>Type: image<span class="hljs-operator">/</span>jpeg

(data)
<span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>WebKitFormBoundary7MA4YWxkTrZu0gW<span class="hljs-operator">-</span><span class="hljs-operator">-</span></span>
</code></pre>
<p>The request includes these headers:</p>
<ol>
<li><code>Host</code>: This header specifies the hostname of the server that the client is trying to connect to.</li>
<li><code>Content-Type</code>: The request is uploading an image file named <code>cat1.jpg</code> using a type of data called <code>multipart/form-data</code>. The image is in JPEG format and its content is included in the request body.</li>
<li><code>x-api-key</code>: This header provides an API key for authentication purposes.</li>
<li><code>Content-Length</code>: This header specifies the length of the request body in bytes. The value of this field is 232.</li>
</ol>
<p>When the server receives this request, it will parse the request body and use it to create a new entry in the Cat API database. The server will then return a response that includes information about the new entry, such as the image URL and the database ID.</p>
<h2 id="heading-what-is-an-http-response">What is an HTTP Response?</h2>
<p>An HTTP response is the message that a server sends back to a client in response to an HTTP request. It usually consists of a status line, headers, and a message body:</p>
<pre><code class="lang-http">HTTP/1.1 <span class="hljs-number">200</span> OK
<span class="hljs-attribute">Date</span>: Sun, 28 Mar 2023 10:15:00 GMT
<span class="hljs-attribute">Content-Type</span>: application/json
<span class="hljs-attribute">Server</span>: Apache/2.4.39 (Unix) OpenSSL/1.1.1c PHP/7.3.6
<span class="hljs-attribute">Content-Length</span>: 1024

<span class="json">{
    <span class="hljs-attr">"name"</span>: <span class="hljs-string">"John Doe"</span>,
    <span class="hljs-attr">"email"</span>: <span class="hljs-string">"johndoe@example.com"</span>,
    <span class="hljs-attr">"age"</span>: <span class="hljs-number">30</span>,
    <span class="hljs-attr">"address"</span>: {
        <span class="hljs-attr">"street"</span>: <span class="hljs-string">"123 Main St"</span>,
        <span class="hljs-attr">"city"</span>: <span class="hljs-string">"Anytown"</span>,
        <span class="hljs-attr">"state"</span>: <span class="hljs-string">"CA"</span>,
        <span class="hljs-attr">"zip"</span>: <span class="hljs-string">"12345"</span>
    }
}</span>
</code></pre>
<p>The status line contains the HTTP version, a status code indicating the outcome of the request, and a corresponding message.</p>
<p>The headers provide additional information about the response, such as the content type of the message body or the date and time that the response was sent.</p>
<p>The message body contains the actual response data, such as HTML, JSON, or XML content.</p>
<p>Some common HTTP status codes include:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Code</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>100</td><td>Continue</td></tr>
<tr>
<td>101</td><td>Switching Protocols</td></tr>
<tr>
<td>200</td><td>OK</td></tr>
<tr>
<td>201</td><td>Created</td></tr>
<tr>
<td>202</td><td>Accepted</td></tr>
<tr>
<td>203</td><td>Non-Authoritative Information</td></tr>
<tr>
<td>404</td><td>Not Found : The requested resource was not found on the server.</td></tr>
<tr>
<td>500</td><td>Internal Server Error : The server encountered an error while processing the request.</td></tr>
<tr>
<td>301</td><td>Moved Permanently: The requested resource has been permanently moved to a new URL.</td></tr>
</tbody>
</table>
</div><p>Here's an example of a JSON response from the Cat API:</p>
<pre><code class="lang-json">{
    <span class="hljs-attr">"id"</span>: <span class="hljs-string">"ErDd1JRRT"</span>,
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://cdn2.thecatapi.com/images/ErDd1JRRT.jpg"</span>,
    <span class="hljs-attr">"width"</span>: <span class="hljs-number">4282</span>,
    <span class="hljs-attr">"height"</span>: <span class="hljs-number">6424</span>,
    <span class="hljs-attr">"original_filename"</span>: <span class="hljs-string">"cat1.jpg"</span>,
    <span class="hljs-attr">"pending"</span>: <span class="hljs-number">0</span>,
    <span class="hljs-attr">"approved"</span>: <span class="hljs-number">1</span>
}
</code></pre>
<p>This is a JSON response from a Cat API request that appears to provide metadata about an image that has been uploaded or retrieved from the API. Here's what each field means:</p>
<ul>
<li><code>id</code>: A unique identifier for the image.</li>
<li><code>url</code>: The URL where the image can be accessed.</li>
<li><code>width</code>: The width of the image in pixels.</li>
<li><code>height</code>: The height of the image in pixels.</li>
<li><code>original_filename</code>: The original name of the file that was uploaded.</li>
<li><code>pending</code>: A flag indicating whether the image is still being processed by the API.</li>
<li><code>approved</code>: A flag indicating whether the image has been approved for public use by the API.</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>HTTP (Hypertext Transfer Protocol) is a protocol used for exchanging information over the internet. It forms the foundation of the World Wide Web and allows communication between web browsers and servers.   </p>
<p>This article is a short introduction to HTTP. If you are interested in learning more, check out these textbook recommendations:</p>
<ul>
<li>"HTTP: The Definitive Guide" by David Gourley and Brian Totty - This book is widely regarded as the authoritative guide to HTTP. It covers the protocol in-depth and provides detailed information on its features and implementation.</li>
<li>"HTTP Pocket Reference" by Clinton Wong - This book provides a concise and portable reference to the HTTP protocol. It covers the essentials of the protocol and is a great resource for developers who need quick access to HTTP information.</li>
<li>"Web Performance Daybook Volume 2: Techniques and Tips for Optimizing Web Site Performance" edited by Stoyan Stefanov - This book is a collection of essays and articles on web performance, including a section on HTTP optimization. It provides practical advice on how to optimize HTTP for faster and more efficient web performance.</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Monetize Your Website with Microtransactions ]]>
                </title>
                <description>
                    <![CDATA[ Web Monetization means that you can get money for every person that visits your website. Sounds good right? But how does it work?  We just published a course on the freeCodeCamp.org YouTube channel that will teach you how to monetize your website usi... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-monetize-your-website/</link>
                <guid isPermaLink="false">66b2033ba8b92c932923645f</guid>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ youtube ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Beau Carnes ]]>
                </dc:creator>
                <pubDate>Mon, 24 Oct 2022 15:37:44 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/08/maxresdefault-2.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Web Monetization means that you can get money for every person that visits your website. Sounds good right? But how does it work? </p>
<p>We just published a course on the freeCodeCamp.org YouTube channel that will teach you how to monetize your website using microtransactions and the Interledger Protocol. </p>
<p>By the end of this crash course you will know:</p>
<ul>
<li>what web monetization is, </li>
<li>how to implement it onto your website to get paid for your hard work,</li>
<li>and how to receive payments.  </li>
</ul>
<p>Ania Kubow developed this course. She is a software developer and course creator on YouTube, as well as your guide to the world of Web Monetization.</p>
<p>While you will learn about many different monetization strategies, this course focusses on one in particular. You will learn how to make money from your website without having to reply on third party advertisers or selling your users data.</p>
<p>The method involves users, who value the service you offer them from your website, paying you a very small payment for visiting your site.</p>
<p>You will learn how to develop a website where users can choose either an ad-supported version or an ad-free premium experience where they pay a small fee.</p>
<p>Watch the full course below or on <a target="_blank" href="https://youtu.be/XwzcrhhyDkc">the freeCodeCamp.org YouTube channel</a> (1-hour watch).</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/XwzcrhhyDkc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ URL Definition ]]>
                </title>
                <description>
                    <![CDATA[ A URL, or universal resource locator, is the location of an online resource. URLs are sometimes called web addresses. Like street addresses, URLs are unique, and lead to specific online resources. These resources could be HTML or CSS files, API endpo... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/url-definition/</link>
                <guid isPermaLink="false">66c36426020f8e9c31066e81</guid>
                
                    <category>
                        <![CDATA[ Tech Terms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ url ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 20 Apr 2021 06:16:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/04/timo-wielink-4Zk45jNyQS4-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>A URL, or universal resource locator, is the location of an online resource.</p>
<p>URLs are sometimes called web addresses. Like street addresses, URLs are unique, and lead to specific online resources. These resources could be HTML or CSS files, API endpoints, and much more.</p>
<p>Here is the URL to freeCodeCamp's homepage: <a target="_blank" href="https://www.freecodecamp.org/">https://www.freecodecamp.org/</a></p>
<p>Tim Berners-Lee created the first specification for the URL in 1994. It built upon the existing domain name structure and added slashes (/) to separate directory and file names like computer file systems.</p>
<p>URLs are made up of several parts, and always include the scheme/protocol, domain name, and path to the file or resource. They may also include the port, parameters, and anchor:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/04/image-107.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/04/mdn-url-all.png" alt="Image" width="600" height="400" loading="lazy">
_Source: <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL">What is a URL?</a>_</p>
<p>The domain names of a URL can be broken down further into a subdomain, second-level domain, and top-level domain.</p>
<p>For example, the freeCodeCamp forum is located at <a target="_blank" href="https://forum.freecodecamp.org/">https://forum.freecodecamp.org/</a>.</p>
<p>In this URL, <code>forum</code> is the subdomain, <code>freecodecamp</code> is the second-level domain, and <code>.org</code> is the top-level domain.</p>
<p>The subdomain is a division of the whole domain, and is a bit like a room in a house. Similar to how a bedroom and bathroom serve totally different purposes, different websites or applications can exist on each subdomain. Common subdomains include <code>www</code>, <code>blog</code>, <code>shop</code>, and <code>m</code> for the mobile version of a site.</p>
<p>The second-level domain is the name of your website or resource, and is how people will find it online. Second-level domains are usually the names of people, companies, or organizations.</p>
<p>The top-level domain, or TLD, can give people some information about your company or organization. For example, <code>.com</code> is a generic TLD that can be used for everything from personal sites to online stores. Meanwhile, <code>.org</code> is meant for nonprofit organizations and communities.</p>
<p>These days there are many different TLDs like <code>.dev</code>, <code>.tech</code>, and <code>.rocks</code>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Everything You Need to Know About Cookies for Web Development ]]>
                </title>
                <description>
                    <![CDATA[ Have you ever wondered how you can sign in to a website once and remain signed in, even if you close your browser? Or added an item to your shopping cart without signing in at all? Whether you know it or not, cookies are everywhere, and for better or... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/everything-you-need-to-know-about-cookies-for-web-development/</link>
                <guid isPermaLink="false">66ac87f29c95a40246abe1b4</guid>
                
                    <category>
                        <![CDATA[ cookies ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kristofer Koishigawa ]]>
                </dc:creator>
                <pubDate>Wed, 03 Feb 2021 06:14:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/602cb40c0a2838549dcc6af3.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Have you ever wondered how you can sign in to a website once and remain signed in, even if you close your browser? Or added an item to your shopping cart without signing in at all?</p>
<p>Whether you know it or not, cookies are everywhere, and for better or worse, they completely changed the way we use the web.</p>
<p>In this article, we'll go over the history of cookies, how they work, how to use them in JavaScript, and some security concerns to keep in mind.</p>
<h2 id="heading-a-brief-history-of-cookies">A brief history of cookies</h2>
<p>HTTP, or the Hypertext Transfer Protocol, is a stateless protocol. According to Wikipedia, its a stateless protocol because it "does not require the HTTP server to retain information or status about each user for the duration of multiple requests."</p>
<p>You can still see this today with simple websites – you type in the URL to the browser, the browser makes a request to a server somewhere, and the server returns the files to render the page and the connection is closed.</p>
<p>Now imagine that you need to sign in to a website to see certain content, like with LinkedIn. The process is largely the same as the one above, but you're presented with a form to enter in your email address and password.</p>
<p>You enter that information in and your browser sends it to the server. The server checks your login information, and if everything looks good, it sends the data needed to render the page back to your browser.</p>
<p>But if LinkedIn was truly stateless, once you navigate to a different page, the server would not remember that you just signed in. It would ask you to enter in your email address and password again, check them, then send over the data to render the new page.</p>
<p>That would be super frustrating, wouldn't it? A lot of developers thought so, too, and found different ways to create stateful sessions on the web.</p>
<h3 id="heading-the-invention-of-the-http-cookie">The invention of the HTTP cookie</h3>
<p>Lou Montoulli, a developer at Netscape in the early 90s, had a problem – he was developing an online store for another company, MCI, which would store the items in each customer's cart on its servers. This meant that people had to create an account first, it was slow, and it took up a lot of storage.</p>
<p>MCI requested for all of this data to be stored on each customer's own computer instead. Also, they wanted everything to work without customers having to sign in first.</p>
<p>To solve this, Lou turned to an idea that was already pretty well known among programmers: the magic cookie.</p>
<p>A magic cookie, or just cookie, is a bit of data that's passed between two computer programs. They're "magic" because the data in the cookie is often a random key or token, and is really just meant for the software using it.</p>
<p>Lou took the magic cookie concept and applied it to the online store, and later to browsers as a whole.</p>
<p>Now that you know about their history, let's take a quick look at how cookies are used to create stateful sessions on the web.</p>
<h2 id="heading-how-cookies-work">How cookies work</h2>
<p>One way to think of cookies is that they're a bit like the wristbands you get when you visit an amusement park.</p>
<p>For example, when you sign in to a website, it's like the process of entering an amusement park. First you pay for a ticket, then when you enter the park, the staff checks your ticket and gives you a wristband.</p>
<p>This is like how you sign in – the server checks your username and password, creates and stores a session, generates a unique session id, and sends back a cookie with the session id.</p>
<p>(Note that the session id is <em>not</em> your password, but is something completely separate and generated on the fly. Proper password handling and authentication is outside the scope of this article, but you can find some in depth guides <a target="_blank" href="https://www.freecodecamp.org/news/search/?query=authentication">here</a>.)</p>
<p>While you're in the amusement park, you can go on any ride by showing your wristband. </p>
<p>Similarly, when you make requests to the website you're signed in to, your browser sends your cookie with your session id back to the server. The server checks for your session using your session id, then returns data for your request.</p>
<p>Finally, once you leave the amusement park, your wristband no longer works – you can't use it to get back into the park or go on more rides. </p>
<p>This is like signing out of a website. Your browser sends your sign out request to the server with your cookie, the server removes your session, and lets your browser know to remove your session id cookie.</p>
<p>If you want to get back into the amusement park, you'd have to buy another ticket and get another wristband. In other words, if you want to continue using the website, you'd have to sign back in.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/fireship-cookies.png" alt="Image" width="600" height="400" loading="lazy">
<em>Source: <a target="_blank" href="https://www.youtube.com/watch?v=UBUNrFtufWo">Session vs Token Authentication in 100 Seconds</a> (YouTube)</em></p>
<p>This is just a simple example of how cookies can be used to keep you signed in to websites. They can be used to remember your setting for dark mode, to track your behavior on a website, and so much more.</p>
<h2 id="heading-how-to-use-cookies">How to use cookies</h2>
<p>Now that you know about the history of cookies and why they're used, let's look at some of the limitations of using cookies, then dive into some simple examples.</p>
<h3 id="heading-cookie-limitations">Cookie limitations</h3>
<p>Cookies are quite limited compared to some modern alternatives to storing data in the browser like <code>localStorage</code> or <code>sessionStorage</code>. Here's a rundown of cookies compared to those other technologies:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td></td><td>Cookies</td><td>Local Storage</td><td>Session Storage</td></tr>
</thead>
<tbody>
<tr>
<td>Capacity</td><td>4KB</td><td>10MB</td><td>5MB</td></tr>
<tr>
<td>Accessible from</td><td>Any window</td><td>Any window</td><td>Same tab</td></tr>
<tr>
<td>Expires</td><td>Manually set</td><td>Never</td><td>On tab close</td></tr>
<tr>
<td>Storage location</td><td>Browser and server</td><td>Browser only</td><td>Browser only</td></tr>
<tr>
<td>Sent with requests</td><td>Yes</td><td>No</td><td>No</td></tr>
</tbody>
</table>
</div><p>Based on: <a target="_blank" href="https://www.youtube.com/watch?v=AwicscsvGLg">cookies vs localStorage vs sessionStorage - Beau teaches JavaScript</a> (YouTube)</p>
<p>Cookies are a much older technology, and have a very limited capacity. Still, there's quite a bit you can do with them. And their small size makes it easy for the browser to send cookies with each request to the server.</p>
<p>It's also worth mentioning that browsers only allow cookies to work from one domain for security reasons.</p>
<p>So if you sign in to your bank at, say, ally.com, then cookies will only work within that domain and its subdomains. For example, your <code>ally.com</code> cookie will work on <code>ally.com</code>, <code>ally.com/about</code>, and the subdomain <code>www.ally.com</code>, but not <code>axos.com</code>.</p>
<p>This means that, even if you have accounts and are signed in at both <code>ally.com</code> and <code>axos.com</code>, those sites won't be able to read each other's cookies.</p>
<p>It's important to remember that your cookies are sent with every request you make in the browser. This is very convenient, but has some serious security implications we'll get into later.</p>
<p>Finally, if there's one thing you take away from this article, just remember that cookies are meant to be openly read and sent, so you should never store sensitive information like passwords in them.</p>
<h3 id="heading-how-to-set-a-cookie-in-javascript">How to set a cookie in JavaScript</h3>
<p>Cookies are really just strings with key / value pairs. Though you'll probably work with cookies more on the backend, there may be times you'll want to set a cookie on the client side.</p>
<p>Here's how to set a cookie in vanilla JavaScript:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=true'</span>
</code></pre>
<p>Then when you open the developer console, click "Application" and then on the site under "Cookies", you'll see the cookie you just added:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/image-101.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>If you take a closer look at your cookie, you'll see that its expiration date is set to <code>Session</code>. That means the cookie will be destroyed when you close your tab / browser.</p>
<p>That might be the behavior you want, like for an online store with payment information.</p>
<p>But if you want your cookie to last longer, you'll need to set an expiration date.</p>
<h3 id="heading-how-to-set-an-expiration-date-on-a-cookie-in-javascript">How to set an expiration date on a cookie in JavaScript</h3>
<p>To set an expiration date, just set the value of your cookie, then add an <code>expires</code> attribute with a date set sometime in the future:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=true; expires=Fri, 26 Feb 2021 00:00:00 GMT'</span> <span class="hljs-comment">// expires 1 week from now</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/image-102.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>JavaScript's <code>Date</code> object should make this much easier and more flexible. You can read more about the <code>Date</code> object <a target="_blank" href="https://www.freecodecamp.org/news/the-ultimate-guide-to-javascript-date-and-moment-js/">here</a>.</p>
<p>Or you could use the <code>max-age</code> attribute with the number of seconds you'd like your cookie to last:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=true; max-age=604800'</span>; <span class="hljs-comment">// expires 1 week from now</span>
</code></pre>
<p>Then when that date rolls around, the browser will automatically remove your cookie.</p>
<h3 id="heading-how-to-update-a-cookie-in-javascript">How to update a cookie in JavaScript</h3>
<p>Whether or not your cookie has an expiration date, updating it is easy.</p>
<p>Just change the value for your cookie, and the browser will automatically pick it up:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">"dark_mode=false; max-age=604800"</span>; <span class="hljs-comment">// expires 1 week from now</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/image-105.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-how-to-set-the-path-for-a-cookie-in-javascript">How to set the path for a cookie in JavaScript</h3>
<p>Sometimes you'll only want your cookie to work with certain parts of your website. Depending on how your website is set up, one way to do this is with the <code>path</code> attribute.</p>
<p>Here's how to make it so a cookie only works on the about page at <code>/about</code>:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=true; path=/about'</span>;
</code></pre>
<p>Now your cookie will only work on <code>/about</code> and other nested subdirectories like <code>/about/team</code>, but not on <code>/blog</code>.</p>
<p>Then when you visit the about page and check your cookies, you'll see it:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/image-103.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h3 id="heading-how-to-delete-a-cookie-in-javascript">How to delete a cookie in JavaScript</h3>
<p>To delete a cookie in JavaScript, just set the <code>expires</code> attribute to a date that's already passed:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=true; expires=Sun, 14 Feb 2021 00:00:00 GMT'</span>; <span class="hljs-comment">// 1 week earlier</span>
</code></pre>
<p>You could also use <code>max-age</code> and pass it a negative value:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=true; max-age=-60'</span>; <span class="hljs-comment">// 1 minute earlier</span>
</code></pre>
<p>Then when you check for your cookie, it'll be gone:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/image-104.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>And that should be everything you need to know about using cookies in vanilla JS.</p>
<p>Everything we covered will work in a pinch, but if you plan on working with cookies extensively, look into libraries like <a target="_blank" href="https://github.com/js-cookie/js-cookie">JavaScript Cookie</a> or <a target="_blank" href="https://github.com/expressjs/cookie-session">Cookie Parser</a>.</p>
<h2 id="heading-security-concerns-with-cookies">Security concerns with cookies</h2>
<p>In general, cookies are very secure when implemented correctly. Browsers have a lot of built-in limitations that we covered earlier, partly due to the age of the technology, but also to improve security.</p>
<p>Still, there are a few ways that a bad actor can steal your cookie and use it to wreak havoc.</p>
<p>We'll go over some common ways this can happen, and look at different ways to fix it. </p>
<p>Also, note that any code snippets will be in vanilla JavaScript. If you want to implement these fixes on the server, you'll need to look up the exact syntax for your language or framework.</p>
<h3 id="heading-man-in-the-middle-attacks">Man-in-the-middle attacks</h3>
<p>A man-in-the-middle (MitM) attack describes a broad category of attacks where an attacker sits between a client and a server and intercepts the data going between the two.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/man-in-the-middle-attack-how-avoid.png" alt="Image" width="600" height="400" loading="lazy">
<em>Source: <a target="_blank" href="https://www.netsparker.com/blog/web-security/man-in-the-middle-attack-how-avoid/">Man-in-the-Middle Attacks and How To Avoid Them</a></em></p>
<p>This can be done in a lot of ways: by gaining access to or listening in on an insecure website, mimicking a public WiFi router, DNS spoofing, or through malware / adware like <a target="_blank" href="https://en.wikipedia.org/wiki/Superfish">SuperFish</a>.</p>
<p>Here's a high-level overview of MitM attacks, and how websites can protect themselves and their users.</p>
<p>Warning: The beginning of the video talks about Mary, Queen of Scotts, and shows an animated depiction of her beheading. It's not overly gruesome, but if you'd like to avoid it, skip ahead to <a target="_blank" href="https://youtu.be/8OR2dDIaIDw?t=57">this timestamp</a>:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/8OR2dDIaIDw" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>As a developer, you can greatly reduce the chance of a MitM attack by ensuring that you enable HTTPS on your server, use an SSL certificate from a trusted certificate authority, and ensure your code uses HTTPS instead of the insecure HTTP.</p>
<p>In terms of cookies, you should add the <code>Secure</code> attribute to your cookies so they can only be sent over a secure HTTPS connection:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=false; Secure'</span>;
</code></pre>
<p>Just remember that the <code>Secure</code> attribute doesn't actually encrypt any data in your cookie – it just ensures that the cookie can't be sent over an HTTP connection.</p>
<p>However, a bad actor could still possibly intercept and manipulate the cookie. To prevent this from happening, you can also use the <code>HttpOnly</code> parameter:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=false; Secure; HttpOnly'</span>;
</code></pre>
<p>Cookies with <code>HttpOnly</code> can only be accessed by the server, and not by the browser's <code>Document.cookie</code> API. This is perfect for things like a login session, where only the server really needs to know if you're signed into a site, and you don't need that information client side.</p>
<h3 id="heading-xss-attacks">XSS attacks</h3>
<p>An XSS (cross-site scripting) attack describes a category of attacks when a bad actor injects unintended, potentially dangerous code into a website.</p>
<p>These attacks are very problematic because they could affect every person that visits the site.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/cross-site-scripting.svg" alt="Image" width="600" height="400" loading="lazy">
<em>Source: <a target="_blank" href="https://portswigger.net/web-security/cross-site-scripting">Cross-site scripting</a></em></p>
<p>For example, if a site has a comments section and someone is able to include malicious code as a comment, it's possible that every person who visits the site and reads that comment will be affected.</p>
<p>In terms of cookies, if a bad actor pulls off a successful XSS attack on a site, they could gain access to session cookies and access the site as another signed in user. From there, they may be able to access the other user's settings, buy things as that user and have it shipped to another address, and so on.</p>
<p>Here's a video that gives a high-level overview of the different types of XSS – Reflected, Stored, DOM-based, and Mutation:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/EoaDgUgS6QA" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>As a developer, you'll want to ensure that your server enforces the Same Origin Policy, and that any input you receive from people is properly sanitized.</p>
<p>And like with preventing MitM attacks, you should set the <code>Secure</code> and <code>HttpOnly</code> parameters with any cookies you use:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=false; Secure; HttpOnly'</span>;
</code></pre>
<h3 id="heading-csrf-attacks">CSRF attacks</h3>
<p>A CSRF (cross-site request forgery) attack is when a bad actor tricks a person into carrying out an unintended, potentially malicious action.</p>
<p>For example, if you're signed into a site and click on a link in a comment, if that link is part of a CSRF attack, it may lead to you unintentionally changing your sign in details, or even deleting your account.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2021/02/cross-site-request-forgery.svg" alt="Image" width="600" height="400" loading="lazy">
<em>Source: <a target="_blank" href="https://portswigger.net/web-security/csrf">Cross-site request forgery</a></em></p>
<p>While CSRF attacks are somewhat related to XSS attacks, specifically reflected XSS attacks where someone inserts malicious code into a site, each preys on a different type of trust.</p>
<p>According to <a target="_blank" href="https://en.wikipedia.org/wiki/Cross-site_request_forgery">Wikipedia</a>, while XSS "exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user's browser."</p>
<p>Here's a video that explains the basics of CSRF, and gives some useful examples:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/eWEgUcHPle0" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>As for cookies, one way to prevent possible CSRF attacks is with the <code>SameSite</code> flag:</p>
<pre><code class="lang-js"><span class="hljs-built_in">document</span>.cookie = <span class="hljs-string">'dark_mode=false; Secure; HttpOnly; SameSite=Strict'</span>;
</code></pre>
<p>There are a few values you can set for <code>SameSite</code>: </p>
<ul>
<li><code>Lax</code>: Cookies are not sent for embedded content (images, iframes, etc.) but are sent when you click on a link or send a request to the origin the cookie is set for. For example, if you're on <code>testing.com</code> and you click on a link to go to <code>test.com/about</code>, your browser will send your cookie for <code>test.com</code> with that request</li>
<li><code>Strict</code>: Cookies are only sent when you click on a link or send a request from the origin the cookie is set for. For example, your <code>test.com</code> cookie will only be sent while you're in and around <code>test.com</code>, and not coming from other sites like <code>testing.com</code></li>
<li><code>None</code>: Cookies will be sent with every request, regardless of context. If you set <code>SameSite</code> to <code>None</code>, you must also add the <code>Secure</code> attribute. It's better to avoid this value if possible</li>
</ul>
<p>Major browsers handle <code>SameSite</code> a bit differently. For example, if <code>SameSite</code> isn't set on a cookie, Google Chrome sets it to <code>Lax</code> by default.</p>
<h2 id="heading-alternatives-to-cookies">Alternatives to cookies</h2>
<p>You might be wondering, if there are so many potential security flaws with cookies, why are we still using them? Surely there must be a better alternative.</p>
<p>These days, you can use either <code>sessionStorage</code> or <code>localStorage</code> to store information that originally used cookies. And for stateful sessions, there's token-based authentication with things like JWT (JSON Web Tokens).</p>
<p>While it may seem like you have to choose between cookie-based or token-based authentication, it's possible to use both. For example, you might want use cookie-based authentication when someone signs in through the browser, and token-based authentication when someone signs in through a phone app.</p>
<p>To muddy the waters a bit more, authentication-as-a-service providers like Auth0 allow you to do both types of authentication.</p>
<p>If you'd like to learn more about web tokens and token-based authentication, check out some of our articles <a target="_blank" href="https://www.freecodecamp.org/news/search/?query=web%20tokens">here</a>.</p>
<h2 id="heading-when-you-give-a-developer-a-cookie">When you give a developer a cookie</h2>
<p>That's it! That should be just about everything you need to know to get started with using cookies, and what to watch out for along the way.</p>
<p>Did you find this useful? How do you use cookies? Let me know over on <a target="_blank" href="https://twitter.com/kriskoishigawa">Twitter</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ HTTP Error 503 Service Unavailable Explained – What the 503 Error Code Means ]]>
                </title>
                <description>
                    <![CDATA[ Errors happen – there's some unexpected maintenance, a bug that went unnoticed, or a page goes viral and the flood of connections take the server down. If you've been online for any amount of time, no doubt you've seen the somewhat vague 503 Service ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/http-error-503-service-unavailable-explained-what-the-503-error-code-means/</link>
                <guid isPermaLink="false">66ac881733a54a9b1a447932</guid>
                
                    <category>
                        <![CDATA[ error ]]>
                    </category>
                
                    <category>
                        <![CDATA[ servers ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kristofer Koishigawa ]]>
                </dc:creator>
                <pubDate>Fri, 02 Oct 2020 02:36:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c986c740569d1a4ca19fd.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Errors happen – there's some unexpected maintenance, a bug that went unnoticed, or a page goes viral and the flood of connections take the server down.</p>
<p>If you've been online for any amount of time, no doubt you've seen the somewhat vague 503 Service Unavailable error.</p>
<p>In this article we'll go over HTTP status codes, what the 503 error means, and some possible ways to solve it – both for a site you're trying to visit and for your own site.</p>
<h2 id="heading-an-overview-of-http-status-codes">An overview of HTTP status codes</h2>
<p>Servers that host web pages listen for requests from web browsers or devices, also known as clients. The server then uses a bunch of different status codes to communicate back.</p>
<p>These status codes are organized into different classes, which is indicated by the first number of the status code:</p>
<ul>
<li>1xx: Information – the server is still processing the request</li>
<li>2xx: Success – the request succeeded and the server responds with the page or resource</li>
<li>3xx: Redirection – the page or resource has moved and server will respond with its new location</li>
<li>4xx: Client error – there is an error in the request from the browser or device</li>
<li>5xx: Server error – there is an error with the server</li>
</ul>
<p>The last two digits of each HTTP status code represent a more specific status for each class. For example, 301 means that a page or resource has moved permanently, while 302 means the move is temporary.</p>
<p>Check out this page for a list of common HTTP status codes and their meaning: <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">https://en.wikipedia.org/wiki/List_of_HTTP_status_codes</a></p>
<p>Most status codes go by totally unnoticed, which is fine because it means everything is working. It's only when you get to the 4xx-5xx range that you might notice a status code because you'll see a page like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/10/E20Ry-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>A typical 503 error page – Source: <a target="_blank" href="https://stackoverflow.com/questions/27944151/asp-net-website-shows-503-service-unavailable-after-successful-publishing">Stack Overflow</a></em></p>
<p>Now that you have a basic understanding of HTTP status codes, let's dig a bit deeper into the 503 Service Unavailable error.</p>
<h2 id="heading-what-does-the-503-error-code-mean">What does the 503 error code mean?</h2>
<p>As mentioned above, 5xx status codes mean there's a problem with the server itself.</p>
<p>A 503 Service Unavailable error means that the page or resource is unavailable. There are many reasons why a server might return a 503 error, but some common reasons are maintenance, a bug in the server's code, or a sudden spike in traffic that causes the server to become overwhelmed.</p>
<p>The message that's sent with the 503 error can vary depending on server it's coming from, but here are some of the common ones you'll see:</p>
<blockquote>
<ul>
<li>503 Service Unavailable  </li>
<li>503 Service Temporarily Unavailable  </li>
<li>HTTP Server Error 503  </li>
<li>HTTP Error 503  </li>
<li>Error 503 Service Unavailable  </li>
<li>The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.  </li>
</ul>
<p><a target="_blank" href="https://kinsta.com/blog/http-error-503/">Source</a></p>
</blockquote>
<p>Whatever the reason for the 503 error, it's usually temporary – the server will restart, traffic will die down, and the issue will resolve itself.</p>
<h2 id="heading-how-to-solve-the-503-status-unavailable-error">How to solve the 503 Status Unavailable error</h2>
<p>When trying to solve a 503 error, there are two general camps.</p>
<p>The first is where you're an end user, and you're trying to visit a site that you don't own. In the second, you own the site, and it's throwing 503 errors to people who are trying to visit.</p>
<p>The method to solve 503 errors is different depending on which group you fall into. Let's take a look at some things you can do as an end user if you see a 503 error.</p>
<h3 id="heading-how-to-solve-a-503-status-unavailable-error-as-an-end-user">How to solve a 503 Status Unavailable error as an end user</h3>
<p>Since 5xx status codes mean that the error is on the server-side, there isn't a lot you can do directly.</p>
<p>Even though 503 errors are usually temporary, there are some things you can do while you wait.</p>
<p><strong>#1: Refresh the page</strong></p>
<p>Sometimes the error is so temporary that a simple refresh is all it takes. With the page open, just press Ctrl - R on Windows and Linux, or Cmd - R on macOS to refresh the page.</p>
<p><strong>#2: See if the page is down for other people</strong></p>
<p>The next thing you can do is use a service like <a target="_blank" href="https://www.isitdownrightnow.com/">Is It Down Right Now?</a> or <a target="_blank" href="https://downforeveryoneorjustme.com/">Down For Everyone Or Just Me</a> to see if other people are getting the same error.</p>
<p>Just go to either of those sites and enter in the URL for the page you're trying to visit.</p>
<p>The service will ping the URL you entered to see if it gets a response. Then it'll show you some cool stats and graphs about the page:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/10/image-44.png" alt="Image" width="600" height="400" loading="lazy">
<em>Checking <a target="_blank" href="https://www.freecodecamp.org/">freeCodeCamp</a> on Is It Down Right Now?</em></p>
<p>If you scroll down a bit you'll see some comments from other people. Often people will give their general location and other data, so this can be a good way to determine if the error is just affecting certain regions or specific devices.</p>
<p><strong>#3: Restart your router</strong></p>
<p>Sometimes the issue has to do with a DNS server failure.</p>
<p>DNS stands for Domain Name System, and they basically act as translators between IP addresses and human readable URLs.</p>
<p>For example, you can visit Google by entering its long IP address directly (172.217.25.206), or you can just enter in the URL, www.google.com.</p>
<p>It's a DNS, often hosted on a server, that handles all that behind the scenes.</p>
<p>All of that is to say, many routers cache responses from DNS servers (www.google.com &lt;==&gt; 172.217.25.206). But sometimes this cache can get corrupted and cause errors.</p>
<p>An easy way to reset or "flush" the cache is to restart your router. Just unplug your router for about 5 seconds, then plug it back in again.</p>
<p>It should restart after a minute and all of your devices should reconnect automatically. Once they do, try visiting the site again.</p>
<h3 id="heading-how-to-solve-a-503-status-unavailable-error-as-the-sites-owner">How to solve a 503 Status Unavailable error as the site's owner</h3>
<p>If you are the owner/developer of the site that's returning 503 errors, there's a bit more you can do to diagnose and resolve the issue.</p>
<p>Here are some general tips to get you started:</p>
<p><strong>#1: Restart the server</strong></p>
<p>Development is tough – even a simple static page can have so many moving parts that it can be difficult to pin down what's causing the 503 error.</p>
<p>Sometimes the best thing to do is to restart the server and see if that fixes the issue.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/10/1rs7t0-1.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Source: <a target="_blank" href="https://imgflip.com/i/1rs7t0">imgflip</a></em></p>
<p>The exact method of restarting your server can vary, but usually you can access it from your provider's dashboard or by SSH'ing into the server and running a restart command.</p>
<p>The server should restart after a couple of minutes. If you've configured everything to run automatically on boot, you can visit your site and see if it's working.</p>
<p><strong>#2: Check the server logs</strong></p>
<p>The next thing to do is check the logs.</p>
<p>The location of the server logs can vary depending on what service you're running, but they're often found in <code>/var/log/...</code>.</p>
<p>Take a look around that directory and see if you can find anything. If not, check the manual for your programs by running <code>man program_name</code>.</p>
<p><strong>#3: Check if there's ongoing automated</strong> maintenance</p>
<p>Some service providers offer automated package updates and maintenance. Normally this is a good thing – they usually occur during downtime, and help make sure everything is up-to-date.</p>
<p>Occasionally 503 errors are due to these scheduled maintenance sessions. </p>
<p>For example, some hosting providers that specialize in WordPress hosting automatically update WP whenever there's a new release. WordPress automatically returns a 503 Service Unavailable error whenever it's being updated.</p>
<p>Check with your service providers to see if the 503 error is being caused by scheduled maintenance.</p>
<p><strong>#4: Check your server's firewall settings</strong></p>
<p>Sometimes 503 Service Unavailable errors are cause by a misconfigured firewall where connections can get through, but fail to get back out to the client.</p>
<p>Your firewall might also need special settings for a CDN, where multiple connections from a small handful of IP addresses might be misinterpreted as a DDoS attack.</p>
<p>The exact method of adjusting your firewall's settings depends on a lot of factors. Take a look at your pipeline and your service provider's dashboards to see where you can configure the firewall.</p>
<p><strong>#5: Check the code</strong></p>
<p>Bugs, like errors, happen. Try as you might, it's impossible to catch them all. Occasionally one might slip through and cause a 503 error.</p>
<p>If you've tried everything else and your site is still showing a 503 Service Unavailable error, the cause might be somewhere in the code.</p>
<p>Check any server-side code, and pay special attention to anything having to do with regular expressions – <a target="_blank" href="https://www.freecodecamp.org/news/freecodecamp-servers-update-october-2019/">a small regex bug</a> is what caused a huge spike in CPU usage, rolling outages, and about three days of panic for us at freeCodeCamp.</p>
<p>Hopefully you'll be able to track down the culprit, deploy a fix, and everything will be back to normal.</p>
<h2 id="heading-in-summary">In summary</h2>
<p>That should be everything you need to know about 503 Service Unavailable errors. While there's usually not much you can do when you see a 503 error, hopefully some of these steps will help the next time you encounter one.</p>
<p>Stay safe, and happy refreshing-until-it-works :)</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ 10 Popular Web Development Tools that Every Programmer Should Know ]]>
                </title>
                <description>
                    <![CDATA[ By Mehul Mohan Are you planning to get into web development? Take a tool with you, it's scary out there. Let's take a look at some common web development tools that'll help you speed up your workflow and be a better web developer. Note that your mile... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/handy-web-development-toolkit/</link>
                <guid isPermaLink="false">66d46051d7a4e35e3843499f</guid>
                
                    <category>
                        <![CDATA[ 100DaysOfCode ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 06 Apr 2020 19:37:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/04/screely-1586183781361.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Mehul Mohan</p>
<p>Are you planning to get into web development? Take a tool with you, it's scary out there. Let's take a look at some common web development tools that'll help you speed up your workflow and be a better web developer.</p>
<p>Note that your mileage may vary a lot. This article just lists the most popular solutions out there in the wild. You still need to integrate them in your projects and learn more about them. </p>
<p>With that being said, here's a list of most common tools/packages I use in my workflows regularly.</p>
<h2 id="heading-1-vscode">#1 VSCode ?</h2>
<p>VSCode needs no introduction. It's a beautiful and powerful code editor that supports extensions, integrated terminal, snippets, themes, shortcuts, remote SSH, and much more - according to your needs. </p>
<p>Running on top of electron, it is cross OS compatible and is constantly improved by Microsoft as an <a target="_blank" href="https://github.com/microsoft/vscode">open source project</a>. VSCode comes with a rich set of tools, IntelliSense through Language Server Protocol, and quick fixes/patches all through the year.</p>
<p><img src="https://code.visualstudio.com/assets/home/home-screenshot-mac-2x.png" alt="VSCode" width="600" height="400" loading="lazy"></p>
<p>Get VSCode now from the official <a target="_blank" href="https://code.visualstudio.com/">VSCode site</a>.</p>
<h2 id="heading-2-webpack">#2 Webpack ?</h2>
<p>Webpack sells itself as a module bundler, but in reality, it is much more extensible than that. You can attach a plethora of plugins and tweak its configuration to make it more robust and fit to your needs. </p>
<p>Webpack 4 comes as a <strong>zero config module bundler</strong> - that means you can get started with Webpack almost immediately! You just have to download the module using <code>npm i webpack</code> and then run <code>npx webpack</code> in your directory. Here's how to setup zero configuration with webpack:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/g9_91gUHy6k" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-3-cypress">#3 Cypress ?</h2>
<p>Cypress is a great e2e testing tool which can actually spin up a headless or a full chrome window to run actual tests of your code. It can interact with asynchronous code in a very intuitive manner. For example, it waits for resources to load/become available, unlike Selenium, which is quite an old technology made for automated testing of mostly static sites. Let's see how Cypress works through a quick video:</p>
<div class="embed-wrapper">
        <iframe width="640" height="360" src="https://player.vimeo.com/video/237527670" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="Vimeo embed" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" loading="lazy"></iframe></div>
<p>Cypress tests are very simple and human-friendly to write, and it does all the heavy lifting out of the box (like launching a chrome instance, proper keyboard events, trusted event emitters, you name it). Get cypress <a target="_blank" href="https://www.cypress.io/">here</a>.</p>
<h2 id="heading-4-typescript">#4 TypeScript ?</h2>
<p>Writing plain JavaScript? It can be really painful to find subtle bugs and errors without proper linting. To make it even more powerful with better type checking and module autocompletion, take TypeScript with you. </p>
<p>TypeScript is a superset of JavaScript which transpiles down to JavaScript before executing. This means that you get JavaScript running just like before, but with the added development benefit of coding JS in a 'stricter' manner. </p>
<p>It wouldn't be wrong to say that TypeScript really enables helpful JavaScript codebase maintenance and makes refactoring a breeze. You can start learning TypeScript through their <a target="_blank" href="https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html">official docs</a>.</p>
<h2 id="heading-5-sentry">#5 Sentry ?</h2>
<p>Sentry is an error reporting service for production. Many a time, especially on the front end, your users might face crashes or unexpected bugs. </p>
<p>I personally use Sentry for <a target="_blank" href="https://codedamn.com">codedamn</a>, and I've fixed quite a few nasty bugs and causes of crashes which were rare and had happened to very specific users during very specific actions taken on the platform. </p>
<p>As a bonus, Sentry exists on a lot of platforms, and is not only restricted to JavaScript runtimes. This means Sentry can be used with mostly any popular tech stack. </p>
<p>Sentry sends full stack trace/information about the bug right into your dashboard so that you can fix that nasty bug on the next release cycle. Read about <a target="_blank" href="https://sentry.io">sentry here</a>.</p>
<div class="embed-wrapper">
        <iframe width="640" height="360" src="https://player.vimeo.com/video/340759078" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="Vimeo embed" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-6-git">#6 Git ?</h2>
<p>Git is the magic wand of any large project. Git is a Version Control System (VCS) allowing you to incrementally build your software, while maintaining a complete diff of the previous builds. This means you don't lose any history and can easily revert back to last working point. </p>
<p>Not only this, you can branch off and work on something completely different, without actually affecting the original project. This concept is called branches in git. There's so much more about git you can learn. I love this series from thenewboston on git. Have a look:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/undefined" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<p>The most popular solution for hosting git repos is GitHub. It offers free public and private repositories. You can learn more about git <a target="_blank" href="https://git-scm.com/">here</a>.</p>
<h2 id="heading-7-babel">#7 Babel ?</h2>
<p>Babel allows you to write bleeding edge JavaScript features, but then transpile them to browsers in a standard those browsers know and have implemented for ages. </p>
<p>Using babel with webpack is a very powerful combination that allows you to use cutting edge features and then bundle/minify them together. This provides the best experience for developers when developing apps as well as for serving minified builds to users for speed and performance.</p>
<p>For example, you can write ES2020 code in babel and let it transpile it down to the ES2015 version to ship to browsers. It makes writing JavaScript really fun and convenient as it allows you to use JavaScript from the future! Learn about babel <a target="_blank" href="https://babeljs.io/">here</a>.</p>
<h2 id="heading-8-material-ui">#8 Material UI ⭐️</h2>
<p>Material UI is a specification from Google on how layouts should be created. On top of Material UI, there are a lot of component libraries available for a number of frameworks like Angular, React, or React Native. Some component libraries include:</p>
<ol>
<li><a target="_blank" href="https://material-ui.com/">Material UI - React</a></li>
<li><a target="_blank" href="https://callstack.github.io/react-native-paper/">React Native paper</a></li>
<li><a target="_blank" href="https://github.com/vuetifyjs/vuetify">Vuetify</a></li>
<li><a target="_blank" href="https://github.com/angular/components">Angular Materials</a></li>
</ol>
<p>This eases the process of building a lot of components manually for developers. And at the same time, it provides them with fast and well-designed components. Learn about Material UI <a target="_blank" href="https://material-ui.com/">here</a>.</p>
<h2 id="heading-9-joi">#9 Joi ?</h2>
<p>Data validation is an important part of any application. This is because you can never trust data coming from a user. For large scale applications with multiple endpoints to reach to backend server, it can become very tricky to handle all the edge cases. </p>
<p>Joi is a very handy library that helps you validate all the incoming data through a strict predefined schema. Joi allows you to construct schemas for arrays, objects and even the values they should accept. </p>
<p>Should the input fail, it also allows you to customize the error messages. No more hassles of <code>obj &amp;&amp; typeof obj === 'string'</code> in your code anymore! Using Joi's schema is not only safe but also makes your code much more readable for other developers. Learn more about Joi <a target="_blank" href="https://github.com/hapijs/joi">here</a>.</p>
<h2 id="heading-10-docker">#10 Docker ?</h2>
<p>Setting up docker for development comes with its own set of challenges (speaking from experience). But once done, it's worth the investment. Partially because you remove the "it-works-on-my-machine" errors. </p>
<p>But also, running sandboxed code has another benefit. In the unfortunate event that your web application is hacked or brought down, the docker container would make sure that the attack is contained to only that particular container and no other service is affected (unless, of course, your container has substandard security rules). </p>
<p>You can get started with Docker today! Start with this playlist:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/avsJnrdN-YU" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h1 id="heading-conclusion">Conclusion</h1>
<p>The web is vast, and if you're just getting started it can be overwhelming to begin! Get some help from fellow developers who've been in your shoes. You can even reach out to me on <a target="_blank" href="https://twitter.com/mehulmpt">twitter</a> / <a target="_blank" href="https://instagram.com/mehulmpt">instagram</a> and connect. I'll be happy to help.</p>
<p>Do you wish to learn web development and other programming languages in a completely new way? Head on to a <a target="_blank" href="https://codedamn.com">new platform for developers</a> I'm working on to try it out today! </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Publish a no-code website in 10 minutes ]]>
                </title>
                <description>
                    <![CDATA[ In this article, I'll introduce a no-code, no-software and no-cost solution to publishing sophisticated web sites managed by non-technical people. The full codebase is on GitHub here. Sir Issac Newton discovered the law of gravity when practicing “so... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/publish-a-no-code-website-in-10-minutes/</link>
                <guid isPermaLink="false">66d4604ec7632f8bfbf1e459</guid>
                
                    <category>
                        <![CDATA[ GitHub ]]>
                    </category>
                
                    <category>
                        <![CDATA[ GitHub Actions ]]>
                    </category>
                
                    <category>
                        <![CDATA[ github pages ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Hugo ]]>
                    </category>
                
                    <category>
                        <![CDATA[ No Code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Static Site Generators ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 28 Mar 2020 20:59:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/03/igor-miske-Px3iBXV-4TU-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, I'll introduce a no-code, no-software and no-cost solution to publishing sophisticated web sites managed by non-technical people. The full codebase is <a target="_blank" href="https://github.com/second-state/hugo-website">on GitHub here</a>.</p>
<p>Sir Issac Newton discovered the law of gravity when practicing “social distancing” during the Plague. What will YOU do? One silver lining of quarantine is that all this free time brings out the entrepreneur spirit and creativity in us.</p>
<p>However, especially because of the quarantine, now more than ever, any new idea or project must have a web site. Traditional CMS solutions like Wordpress, Squarespace, or Wix are difficult to use, look dated, are expensive, or all of the above!</p>
<p>We wanted to create a web site that has a sophisticated look and feel, yet is easy to customize. A non-technical person should be able to edit the source files and see the changes appear on the live web site in a few minutes. Ideally, it should also be free (forever free, not just free-for-now), and can scale to handle millions of visitors if it becomes popular.</p>
<p>Is this possible?</p>
<p>In this short article, I will walk you through a solution based on the Hugo framework, GitHub Pages, and GitHub Actions. You can get up and running with your shiny new website by the end of this article.</p>
<blockquote>
<p>It is so easy that my 9-year-old son did it. He now manages a web site for his fictional country called <a target="_blank" href="https://www.arenztopia.com/">Arenztopia</a>. Check out the <a target="_blank" href="https://medium.com/@michaelyuan_88928/welcome-to-arenztopia-95cc85253163">back story</a>.</p>
</blockquote>
<h2 id="heading-tldr">TL;DR</h2>
<p>If you just want to get started with a working web site as soon as possible, first make sure that you have a free GitHub account.</p>
<p>Go to <a target="_blank" href="https://github.com/second-state/hugo-website">this GitHub repository</a>, and click on the “Fork” button on the top right, and <strong>fork</strong> it to your own account.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_edHfJdOu6Ppjiyd-M4tMJQ.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Go to your forked repository, and click on the Actions tab. You will see a message like the one in the picture below. <strong>Click on</strong> the “I understand my workflows …” button.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_nCrYAyGhCmLeFC2PMbUBEA.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Go to the Settings tab of your repository, and then scroll down to GitHub Pages. <strong>Re-select</strong> the <code>gh-pages</code> from the dropdown for the web site to build.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_K4qXL2CN2rtMonI4dXRWnA.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Go to the Code tab of the repository, open the <code>config.toml</code> file, and edit it. <strong>Change</strong> its <code>title</code> attribute to something else, and click on the “Commit changes” button at the bottom. We need this step to trigger the workflow at the new repository.</p>
<p>Wait a few minutes, go to the “published at” web address at GitHub Pages and you will see the template web site.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_WRQaxyvCqagRMfsN6T1B_A.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Next, you can customize the site by editing the <code>config.toml</code> file and the files in the <code>content</code> folder. Go to the “Add your own content” section at the end of this article to see how. You can check out <a target="_blank" href="https://github.com/budparr/gohugo-theme-ananke#getting-started">the instructions for the Ananke theme here</a>.</p>
<p>That’s it for the quick start! In the next several sections, I will explain in more detail the concepts and processes.</p>
<h2 id="heading-hugo-basics">Hugo basics</h2>
<p>Older generation CMS solutions like Wordpress are too difficult to adapt to new web site designs, and commercially hosted solutions like SquareSpace are too expensive and not flexible enough. Static web site generators like Hugo offer a good balance among features, flexibility, and ease of authoring.</p>
<ul>
<li><p>Hugo web sites can be customized and modified through configuration files.</p>
</li>
<li><p>New pages and content sections can be written in markdown instead of HTML. That makes content authoring much easier.</p>
</li>
<li><p>There are many modern design themes to choose from.</p>
</li>
<li><p>The output of Hugo is a static HTML web site that can be deployed on any low-cost hosting provider.</p>
</li>
<li><p>Together with static web site hosting services like GitHub Pages and Netlify, they can offer a completely free solution.</p>
</li>
</ul>
<p>The Hugo software distribution is <a target="_blank" href="https://gohugo.io/getting-started/installing/">available</a> on all major operating systems. You can <a target="_blank" href="https://gohugo.io/getting-started/quick-start/">learn about it here</a>. But, since we will use GitHub Actions to automatically build our Hugo web sites, we do not actually need to install Hugo software here.</p>
<p>Here is how to do it.</p>
<h2 id="heading-create-a-template-website">Create a template website</h2>
<p>First, select a Hugo theme. There are <a target="_blank" href="https://themes.gohugo.io/">many</a>. Some are geared toward web sites with one or more content web pages, while others are optimized for blog-like sites with timestamped posts.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_CjWlyVScCKNkxDIxshwYTQ.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Hugo themes</em></p>
<p>Find one you like, download a zip package or clone a GitHub repo, and unpack the theme into a folder. Let’s assume that the theme distribution is unpacked into a folder called <code>my-theme</code>. The following are commands in a Linux terminal. You could use the Terminal app on Mac or PowerShell on Windows.</p>
<p>Next, create your web site project directory on your computer.</p>
<pre><code class="lang-javascript">$ mkdir -r my-site/themes
</code></pre>
<p>Copy the theme folder into your project.</p>
<pre><code class="lang-javascript">$ cp -r my-theme my-site/themes
</code></pre>
<p>Next, copy the theme’s <code>exampleSite</code> to the project’s top-level directory.</p>
<pre><code class="lang-javascript">$ cd my-site
$ cp -r themes/my-theme/exampleSite<span class="hljs-comment">/* ./</span>
</code></pre>
<p>Edit the <code>config.toml</code> in the project root directory <code>my-site/</code> to point to the right theme.</p>
<pre><code class="lang-javascript">baseURL = <span class="hljs-string">"/"</span>themesDir = <span class="hljs-string">"themes"</span>theme = <span class="hljs-string">"my-theme"</span>
</code></pre>
<p>Next, create a GitHub repo called <code>my-site</code>, and push the <code>my-site</code> directory onto its <code>master</code> branch. Here are the steps for <a target="_blank" href="https://help.github.com/en/github/managing-files-in-a-repository/adding-a-file-to-a-repository">uploading files from GitHub’s web UI</a>. Now we are ready to publish the theme example site.</p>
<p>For a Hugo-based system to be useable to a non-developer (or a young developer who has yet to master the command line tools), we must automate the process of building and deploying the static web site.</p>
<h2 id="heading-automate-deployment">Automate deployment</h2>
<p>In the GitHub project, go to Settings and enable GitHub Pages. Select the source to be the <code>gh-pages</code> branch.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_TrbrZti-GFpVBK0HtrezcA.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Settings, GitHub Pages</em></p>
<p>Next, we create a GitHub Actions workflow to run the Hugo command on the source files from <code>master</code> branch, and push the generated HTML files to the <code>gh-pages</code> branch for publication. From the project’s Actions tab, click on the “set up a workflow yourself” button.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_b5UuewhfFq2Gfa0vwJ8bqw.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Set up a workflow yourself</em></p>
<p>The workflow is stored in the <code>master</code> branch as <code>.github/workflows/main.yml</code> file. The content of the file is as follows.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">name:</span> <span class="hljs-string">github</span> <span class="hljs-string">pages</span>

<span class="hljs-attr">on:</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">master</span>

<span class="hljs-attr">jobs:</span>
  <span class="hljs-attr">deploy:</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-18.04</span>
    <span class="hljs-attr">steps:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v1</span>  <span class="hljs-comment"># v2 does not have submodules option now</span>
        <span class="hljs-comment"># with:</span>
        <span class="hljs-comment">#   submodules: true</span>

      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Setup</span> <span class="hljs-string">Hugo</span>
        <span class="hljs-attr">uses:</span> <span class="hljs-string">peaceiris/actions-hugo@v2</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">hugo-version:</span> <span class="hljs-string">'0.62.2'</span>
          <span class="hljs-attr">extended:</span> <span class="hljs-literal">true</span>

      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Build</span>
        <span class="hljs-attr">run:</span> <span class="hljs-string">hugo</span>

      <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Deploy</span>
        <span class="hljs-attr">uses:</span> <span class="hljs-string">peaceiris/actions-gh-pages@v3</span>
        <span class="hljs-attr">with:</span>
          <span class="hljs-attr">github_token:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.GITHUB_TOKEN</span> <span class="hljs-string">}}</span>
          <span class="hljs-attr">publish_dir:</span> <span class="hljs-string">./public</span>
</code></pre>
<p>What happens here is that the web site authors and editors will change content and files on the <code>master</code> branch. Whenever new content is pushed to the <code>master</code> branch, the automated GitHub Actions workflow will <a target="_blank" href="https://github.com/peaceiris/actions-hugo/blob/master/README.md">set up the Hugo software</a>, run the <code>hugo</code> command, and turn those files into HTML files for a static web site.</p>
<p>The HTML files are <a target="_blank" href="https://github.com/peaceiris/actions-gh-pages/blob/master/README.md">pushed</a> to the <code>gh-pages</code> branch of the same repository. They will be published on the specified web address by GitHub Pages as configured.</p>
<p>Notice the <code>cname</code> attribute in the last line. That is the <a target="_blank" href="https://help.github.com/en/github/working-with-github-pages/configuring-a-custom-domain-for-your-github-pages-site">custom domain name</a> we set up with GitHub Pages. If you do not have a custom domain name, just remove this line, and you can access your web site at the domain provided by GitHub Pages.</p>
<p>Now go to the web site, and you should see the theme’s default web page.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/03/1_fkJkt7YXYEZX96Qv3v5u8A.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>The HugoSerif template for one of our web sites.</em></p>
<h2 id="heading-add-your-own-content">Add your own content</h2>
<p>To change the default theme web site to your own content, you just need to change the files on the <code>master</code> branch. Please refer to the <a target="_blank" href="https://gohugo.io/content-management/organization/">documentation</a> of your selected theme. In general, Hugo templates work like this:</p>
<ul>
<li><p>The web pages are authored in markdown format and the <code>md</code> files are in the <code>content</code> folder.</p>
</li>
<li><p>Each <code>md</code> file has a header section with properties such as the page’s menu placement, priority, timestamp, excerpt, etc.</p>
</li>
<li><p>The overall configuration, such as the menu items and properties used by multiple pages, are stored in the <code>data</code> folder.</p>
</li>
<li><p>Static content such as raw HTML files, JavaScript files, and image files can be placed in the <code>static</code> folder.</p>
</li>
</ul>
<p>In particular, here is how you customize the Ananke theme that comes with our template:</p>
<ul>
<li><p>The <a target="_blank" href="https://github.com/second-state/hugo-website/blob/master/config.toml">config.toml</a> file allows you to configure the website title, social icons on all pages, and the big featured image on the home page.</p>
</li>
<li><p>All images should be uploaded to the <a target="_blank" href="https://github.com/second-state/hugo-website/tree/master/static/images">static/images</a> folder.</p>
</li>
<li><p>The <a target="_blank" href="https://github.com/second-state/hugo-website/blob/master/content/_index.md">content/_index.md</a> file contains the text for the home page.</p>
</li>
<li><p>To add pages to the site, you can just create <a target="_blank" href="https://guides.github.com/features/mastering-markdown/">markdown</a> files in the <a target="_blank" href="https://github.com/second-state/hugo-website/tree/master/content">content</a> folder. An example is the <a target="_blank" href="https://github.com/second-state/hugo-website/blob/master/content/contact.md">contact.md</a> file. Notice that at the top of the file, there are attributes to control whether this page should be on the website menu.</p>
</li>
<li><p>To add articles to the site, you can create markdown files in the <a target="_blank" href="https://github.com/second-state/hugo-website/tree/master/content/post">content/post</a> folder. Those are blog-like content articles that have dates and titles at the top. The most recent two articles will show up on the home page.</p>
</li>
</ul>
<p>If you are interested in learning more and see how we did it, you can watch our progress at</p>
<ul>
<li><p>The Country of Arenztopia [<a target="_blank" href="https://github.com/juntao/arenztopia">GitHub</a>] [<a target="_blank" href="https://www.arenztopia.com/">Web site</a>]</p>
</li>
<li><p>Second State blog [<a target="_blank" href="https://github.com/second-state/blog">GitHub</a>] [<a target="_blank" href="https://blog.secondstate.io/categories/en/">Web site</a>]</p>
</li>
</ul>
<p>Good luck and stay healthy!</p>
<h2 id="heading-about-the-author">About the author</h2>
<p>Dr. Michael Yuan is the <a target="_blank" href="http://www.michaelyuan.com/">author of 5 books</a> on software engineering. His latest book <a target="_blank" href="https://www.buildingblockchainapps.com/">Building Blockchain Apps</a> was published by Addison-Wesley in Dec 2019. Dr. Yuan is the co-founder of <a target="_blank" href="https://www.secondstate.io/">Second State</a>, a VC-funded startup that brings WebAssembly and Rust technologies to <a target="_blank" href="https://www.secondstate.io/articles/why-webassembly-server/">cloud</a>, <a target="_blank" href="https://docs.secondstate.io/">blockchain</a>, and <a target="_blank" href="https://github.com/second-state/rust-wasm-ai-demo/blob/master/README.md">AI</a> applications. It enables developers to deploy fast, safe, portable, and serverless <a target="_blank" href="https://www.secondstate.io/articles/getting-started-with-rust-function/">Rust functions on Node.js</a>.</p>
<div class="embed-wrapper"><iframe src="https://webassemblytoday.substack.com/embed" width="480" height="320" style="border:1px solid #EEE;background:white" title="Embedded content" loading="lazy"></iframe></div>

<p>Prior to Second State, Dr. Yuan was a long time open source contributor at Red Hat, JBoss, and Mozilla. Outside of software, Dr. Yuan is a Principal Investigator at the National Institutes of Health, with multiple research awards on cancer and public health research. He holds a PhD in astrophysics from the University of Texas at Austin.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How I did NOT code a collaborative writing app ]]>
                </title>
                <description>
                    <![CDATA[ By Eric Burel Twaikura, haikus but funnier As easy as ABC: some stranger on the Internet starts a 120 characters story, some stranger on the Internet finishes it. And that makes a Twaiku (tweet + haiku). Twaikus can be funny, serious, artistic, it’s ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-i-did-not-code-a-collaborative-writing-app/</link>
                <guid isPermaLink="false">66d45e3f4a7504b7409c3382</guid>
                
                    <category>
                        <![CDATA[ bubble ]]>
                    </category>
                
                    <category>
                        <![CDATA[ code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Entrepreneurship ]]>
                    </category>
                
                    <category>
                        <![CDATA[ lean startup ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 18 Feb 2020 17:19:33 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/02/code-free-1200-2.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Eric Burel</p>
<h2 id="heading-twaikura-haikus-but-funnier">Twaikura, haikus but funnier</h2>
<p>As easy as ABC: some stranger on the Internet starts a 120 characters story, some stranger on the Internet finishes it. And that makes a Twaiku (tweet + haiku). Twaikus can be funny, serious, artistic, it’s up to you. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/logo_256.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/twaiku.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>So, as a developer, implementing something like that shouldn't be hard, right? Yes, but no. Here is the story of how it took me multiple years to create Twaikura and how you could do the same in a matter of hours.</p>
<h2 id="heading-back-to-twentyparts-and-why-it-never-came-to-existence">Back to TwentyParts and why it never came to existence</h2>
<p>TwentyParts was my first “entrepreneurial concept” back in 2015. As you may guess, the idea is to write a story in 20 parts, with each part written by a different author. </p>
<p>I was a CS student at the time and it took me 2 months to release a first draft. The result was disastrous. I didn’t even know about the concept of a “framework”, picture the code. The concept was too complex, the interface unusable.</p>
<p>I did not give up. A few months later, in 2016, I came up with a simplified version of TwentyParts, HiKoo.  I limited the length of a story to 3 tweets. And instead of rushing to development, I created mocks using a marvelous tool named MarvelApp.</p>
<p>Now I had a great UI and all, but no working code. One more app that never came to existence.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/hikoo.png" alt="Image" width="600" height="400" loading="lazy">
<em>Looks good, doesn't work</em></p>
<p>Fast forward to now. I’ve graduated. I’ve built my consulting company, LBKE. I’ve developed complex SaaS platforms for multiple clients. And I've kept this question running in my head:</p>
<blockquote>
<p>What prevents me from recreating TwentyParts, now I am fast and skilled and over-confident?</p>
</blockquote>
<p>After all, it would only take a full work week nowadays. Yet there’s a problem: I am not a student anymore. With one spare hour here and there, a “full work week“ can span over a few months. Too slow.</p>
<h2 id="heading-how-to-code-fast-dont">How to code fast: don’t.</h2>
<p>I’ve explored thoroughly the realms of fast web development. You may have read my previous articles on freeCodeCamp about <a target="_blank" href="https://www.freecodecamp.org/news/how-i-built-an-app-with-vulcan-js-in-four-days-6368814077b1/">Vulcan, a framework based on Meteor that makes me very productive.</a></p>
<p>Those researches all lead me to the same conclusion: the best code is the code you don’t write. </p>
<p>There are a lot of ways NOT to write code, even for a developer. Scaffolding, declarative programming, using snippets, or using an ORM are all methods to circumvent writing code. Using open source is another great example. Some may even think that developers are a bit lazy – but aren't they?</p>
<p>Yet minimal skills in web development are still necessary. That means careful thinking, lots of doc reading, debugging and so on. In the end, the time needed to create a fully functional app can only be reduced this much.</p>
<p>You know what? Using a massive framework to speed up developments feels like cheating sometimes. What if I did not have those skills? What if I was not a developer? I would have no other choice than embracing the “no-code way”. And that’s what I’ve done.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/code-free-1200.png" alt="Image" width="600" height="400" loading="lazy">
<em>Relax, Code will be on vacation for the remainder of this article</em></p>
<h2 id="heading-sparkling-innovations-for-web-non-developers">Sparkling innovations for web non-developers</h2>
<p>No-code solutions have been pretty bad in the past. Limited, difficult to extend, proprietary, expensive, the list is long. But some recent tools are starting to be worthy enough.</p>
<p>I will focus specifically on Bubble. Its plugin system coupled with its data management features makes it the most complete solution on the market currently. Here are a few key features and how I used them to build Twaikura.</p>
<h3 id="heading-the-ui-editor">The UI editor</h3>
<p>Bubble proposes a WYSIWYG editor (What You See Is What You Get) to create the app user interface. You put your blocks of content wherever you want, and configure their content.</p>
<p>It’s grid-based so you can have pixel perfect alignment. It handles responsiveness. So you should be able to create designs as complex as you wish.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/ui-bubble.png" alt="Image" width="600" height="400" loading="lazy">
<em>Building Twaikura's interface using the WYSIWYG editor.</em></p>
<p>But I’ll be honest, I am not the hugest fan. More precisely, I am not very good with it. It’s very different both from writing HTML/CSS and from using web-based design tools like Figma, so there is a learning curve.</p>
<p>I ended up sticking myself to an old school Windows 98-ish style. With a little bit of imagination you could even believe it has some “V a p o r w a v e” aesthetic.</p>
<h3 id="heading-thinking-in-workflows">Thinking in workflows</h3>
<p>The most impressive feature of Bubble to me is its “Workflows”. It lets you describe complex process in a visual language. It can mix data management (validating and storing a Twaiku, sending an email) and user experience (resetting a form, refreshing the page) transparently. You don’t need to mentally split the workflow between frontend and backend as you would do in a traditional web app.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/workflows.png" alt="Image" width="600" height="400" loading="lazy">
<em>Twaiku creation workflow</em></p>
<p>This example workflow is triggered when the user wants to submit the second part of a Twaiku. It will create a "Twaiku End" in the database, link it with a "Twaiku Begin", and reset the form. I could also display a success message, send a mail to a moderator and so on. Visualizing the full workflow in a single timeline is very intuitive.</p>
<h3 id="heading-complete-data-management">Complete data management</h3>
<p>Bubbles comes with a relational database and complete filtering features. That means you can easily create both forms and list of data. For example, the “Read latest Twaikus” block will load all valid Twaikus.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/02/twaikus-list.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Plugins can help secure your content. For example, there is a ReCaptcha plugin to add CAPTCHAs to your form in a matter of minutes. This is important as security is usually left behind in the prototyping steps. Malevolent bots and hackers don't care that you are a "lean startup-er", and they won't miss an opportunity to spam or hack your website.</p>
<h2 id="heading-a-few-hours-of-work-for-an-app-that-works">A few hours of work for an app that works</h2>
<p>I won’t describe all features of Bubble, because it has a lot more. The conclusion is that it's been powerful enough to write an app like Twaikura. Instead of writing tons of crappy code that will end up in a dumpster, instead of creating a visual prototype as lively as Frankenstein’s Creature, I just created something that works.</p>
<p>Is my website great? Honestly, not yet. Does it do the job? Hell yes. I had fun creating it, it cost me no more than a few hours, and I am able to test the concept in the most direct possible way. The longest part was writing this article.</p>
<p>I especially recommend no-code tools for people who want to learn web development. Taking a lot of time to produce simple features can feel frustrating at first. Using a no-code tool alongside traditional programming is a way to keep having fun. It's instructive too, because, even if you don't write code, you still have to think like a developer: designing conditional workflows, structuring a database, validating forms... That's a win-win.</p>
<p>I won't become a no-code evangelist, but Bubble is a great addition to my tool belt. And it could be great addition to yours too!</p>
<p>Thanks for the read. If you liked this article, come try a Bubble app by creating your first Twaiku on <a target="_blank" href="http://twaikura.com">twaikura.com</a>!</p>
<p><a href="https://twitter.com/lbke_fr">
<img src="https://www.freecodecamp.org/news/content/images/2019/10/Medium-follow-2019.png" alt="LBKE banner twitter" width="600" height="400" loading="lazy">
</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ If the code works, don't fix it... Or maybe do? When to refactor your code and when to leave it alone. ]]>
                </title>
                <description>
                    <![CDATA[ By Huseyin Polat Yuruk Imagine software that you work on. It was written by programmers before you joined the team and the software works properly. There are some bugs that need to be fixed but it does what it’s supposed to do. Nothing else. This is ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/advice-to-programmers-if-it-works-dont-fix-it-or/</link>
                <guid isPermaLink="false">66d84fedef84e4cc27cfbe49</guid>
                
                    <category>
                        <![CDATA[ coding ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ self-improvement  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 30 Oct 2019 18:51:06 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/10/1_ShTnBApvIxNlKjTItTAAiw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Huseyin Polat Yuruk</p>
<p>Imagine software that you work on. It was written by programmers before you joined the team and the software works properly. There are some bugs that need to be fixed but it does what it’s supposed to do. Nothing else. This is what others see from outside of the code–software that solves customers’ problems and works as expected.</p>
<p>But what about the code? What about the programmers? What do they think about their software?</p>
<p>As one of the programmers that built this software, you see totally different things from inside the code. </p>
<p>First things first, you think the code base is so big. You know certainly that this software could have been written with much less code while still providing the same functionality. The code base seems so complex to you. You know that the code could have been written in a better, simpler, and more well-structured way. </p>
<p>Adding new features or implementing something new is hard and painful because you have to consider the other parts that are connected to each other. The modules are not loosely coupled, so making changes takes too much time. And what about debugging? Finding bugs and fixing them takes too much time as well.</p>
<p>Besides the bad design and ugly code, the software works properly and the customers are happy. Now you are at the crossroads. There are two possible ways for you: one way tells you that you should follow the old engineering adage, “If it works, don’t fix it.” The other one that tells you that you should do some refactoring to make your job easier while working on your code base so that you have more readable and understandable code. </p>
<p>Which way would you prefer? Would you follow the old engineering adage “If it works, don’t fix it?”</p>
<h2 id="heading-two-different-programmer-mindsets">Two different programmer mindsets</h2>
<p>The answer to that question can be simple. But before explaining the appropriate answer, I want to introduce you to two different programmer’s mindsets when it comes to fixing bad code that works properly.</p>
<p>The first mindset believes in the old engineering adage: “<strong>If it works, don’t fix it.</strong>” To them, their code style doesn’t matter. They are result-driven programmers. It can be complex, badly structured code, completely opposite of important programming principles, but they don’t care about how well the code is written. They just care about what it does. </p>
<p>So to these programmers, fixing badly written code is a waste of time. It just works. Why should they touch it?! And besides, there is a big risk of introducing new bugs while fixing the bad code. So what will they do? They will not touch the code and continue following the old engineering adage.</p>
<p>On the other hand, the other programmers who see the code as artwork will be uncomfortable with that kind of situation. They will feel disgusted while reading badly written code. They will try to fix each piece of code in the project because they care about code style a lot, and every piece of code in their project should be treated as art. </p>
<p>They are too obsessive about their code style. Even if other programmers write well-structured code, they will try to change that code to make it suitable to their own style. So basically they don’t follow the old “if it works, don’t fix it” adage. They will fix everything according to their own mindset. In the end, it doesn’t matter to them if it works or not.</p>
<h2 id="heading-what-would-be-the-best-solution-that-works-for-you">What would be the best solution that works for you?</h2>
<p>Find the parts of code that you work on actively and fix these parts to make them more understandable and readable. Don’t touch other parts if they work as expected and they are bug-free. </p>
<p>Why is this core so important? The core parts of your software are the parts you will work on the most. You will read these parts more often and will make changes in them more often than the rest. If there is a need for adding additional functionalities or implementing new features, they will be connected directly to the core. </p>
<p>Most of the bugs will be introduced from this core, which means you will spend most of your time debugging these parts. Remember the <a target="_blank" href="https://en.wikipedia.org/wiki/Pareto_principle">80/20 rule (Pareto Principle)</a>, <strong>“20 percent of the code has 80 percent of the errors. Find them, fix them!”</strong></p>
<p>What about the other parts?</p>
<p>Those parts are the ones that you will rarely work on. They are bug-free. They were written maybe even months or years ago and they work as expected. They might be written in an ugly way, even though they could have been written in a simpler, more readable and understandable way. This doesn’t mean that you have to fix them too. God knows when you will have to read them or change them again. So these parts can stay as they are. Forget about them. No need to fix them. You can spend your time working on more important stuff.</p>
<h2 id="heading-why-is-fixing-core-parts-so-important-even-if-they-work-as-expected">Why is fixing core parts so important even if they work as expected?</h2>
<p>If you want to serve your customers for many years, you should have a maintainable product. A maintainable product means that making changes is not a struggle. Debugging and fixing bugs shouldn’t take too much time and adding new features should also be easy. So as a result, your programmers are happy and your customers are happy, too.</p>
<p>As <a target="_blank" href="https://martinfowler.com/">Martin Fowler</a> said in his <a target="_blank" href="https://www.amazon.com/Refactoring-Improving-Existing-Addison-Wesley-Signature/dp/0134757599/ref=pd_sbs_14_img_0/147-2543130-6817650?_encoding=UTF8&amp;pd_rd_i=0134757599&amp;pd_rd_r=3126d0ac-cc44-40ab-874c-dd6a2817a30a&amp;pd_rd_w=NxgDY&amp;pd_rd_wg=nvdiq&amp;pf_rd_p=5cfcfe89-300f-47d2-b1ad-a4e27203a02a&amp;pf_rd_r=AB27YQ6VJP9RM58D8HBD&amp;psc=1&amp;refRID=AB27YQ6VJP9RM58D8HBD">Refactoring book</a>:</p>
<blockquote>
<p>“When you think about programmers, most of us will think that they spend most of their time writing code. Actually, this is quite a small fraction. Programmers spend most of their time reading the code and debugging it. Every programmer can tell a story of a bug that took a whole day (or more) to find. Fixing the bug is usually pretty quick, but finding it is a nightmare.”</p>
</blockquote>
<p>The more well-written code you have, the easier it is to understand the code. The more understandable your code is, the easier your job is.</p>
<p>That is the reason why not following the old engineering adage (if it works, don’t fix it) for the core parts of your software is an important decision you can make.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Story of requesting twice - CORS ]]>
                </title>
                <description>
                    <![CDATA[ By Lusan Das The story of requesting twice, allow me to explain how it all began. While working on a feature, I decided to look at the network tab and observed that the first request was sent with method OPTIONS, and the following request after it wa... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-story-of-requesting-twice-cors/</link>
                <guid isPermaLink="false">66d45e09d1ffc3d3eb89ddbf</guid>
                
                    <category>
                        <![CDATA[ api ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CORS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ REST API ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web App Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 13 Jun 2019 06:25:10 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/06/priscilla-du-preez-234144-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Lusan Das</p>
<p>The story of requesting twice, allow me to explain how it all began.</p>
<p>While working on a feature, I decided to look at the network tab and observed that the first request was sent with method OPTIONS, and the following request after it was the request with the correct method eg GET, POST etc, which is returning the expected payload. Basically two calls for the same request.</p>
<p>Here take a look at the screen shots below</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*W7g8e0J9fwocmwX_Ce6VWA.png" alt="Image" width="1600" height="625" loading="lazy"></p>
<p><em>Request with OPTIONS method</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*JgwOpH3t9oTrL8Q_UM01mw.png" alt="Image" width="1600" height="712" loading="lazy"></p>
<p><em>Request with GET method</em></p>
<p>After digging few docs, I realised it was an expected behaviour. It is related to the concept of HTTP access control (CORS).</p>
<p>To understand it better, let me explain a bit about CORS and requests.</p>
<h3 id="heading-http-access-control-cors">HTTP access control (CORS)</h3>
<p>Cross-Origin Resource Sharing (<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/CORS">CORS</a>) is a mechanism that uses additional <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/HTTP">HTTP</a> headers to let a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/user_agent">user agent</a> gain permission to access selected resources from a server on a different origin (domain) than the site currently in use.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*wnTTrWj5tn6VCQJHk9PHKQ.png" alt="Image" width="925" height="643" loading="lazy"></p>
<p><em>Cross-Origin Resource Sharing (</em><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/CORS"><em>CORS</em></a><em>)</em></p>
<p>Let us understand the above image above to get a better understanding of CORS.</p>
<ol>
<li><p><strong>Same Origin Request:</strong> We have opened <strong>domain-a.com</strong>, where we are requesting a <strong>blue image</strong> hosted in web server <strong>domain-a.com.</strong> Since we are performing our requests in the same domain, it is called a Same-origin request.</p>
</li>
<li><p><strong>Cross Origin Request:</strong> We have opened <strong>domain-a.com</strong>, where we are requesting a <strong>red image</strong> hosted in web server <strong>domain-b.com.</strong> Since we are performing our requests in different domains, it is called a Cross-origin Request.</p>
</li>
</ol>
<h3 id="heading-simple-requests"><strong>Simple requests</strong></h3>
<p>These are requests that doesn't send it’s first request as method OPTIONS. It is fired only once.</p>
<p>Surely it begs the question, why will the first request have method OPTIONS if we are not sending it, please have patience it will be explained below in preflight section ☺</p>
<p>But before that let us understand what are the points that make request simple.</p>
<ol>
<li>The only allowed methods in simple request are:</li>
</ol>
<ul>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET">GET</a></p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD">HEAD</a></p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST">POST</a></p>
</li>
</ul>
<ol start="2">
<li>Apart from the headers set automatically by the user agent (for example, connection , <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent">User-Agent</a>, or any of the other headers with names defined in the Fetch spec as a “forbidden header name”), the only headers which are allowed to be manually set are <a target="_blank" href="https://fetch.spec.whatwg.org/#cors-safelisted-request-header">those which the Fetch spec defines as being a “CORS-safelisted request-header”</a>, which are:</li>
</ol>
<ul>
<li><p>Accept</p>
</li>
<li><p>Accept-Language</p>
</li>
<li><p>Content-Language</p>
</li>
<li><p>Content-Type</p>
</li>
<li><p>DPR</p>
</li>
<li><p>Downlink</p>
</li>
<li><p>Save-Data</p>
</li>
<li><p>Viewport-Width</p>
</li>
<li><p>Width</p>
</li>
</ul>
<ol start="3">
<li>The only allowed values for the Content-Type header are:</li>
</ol>
<ul>
<li><p>application/x-www-form-urlencoded</p>
</li>
<li><p>multipart/form-data</p>
</li>
<li><p>text/plain</p>
</li>
</ul>
<ol start="4">
<li><p>No event listeners are registered on any XMLHttpRequestUpload object used in the request.</p>
</li>
<li><p>No ReadableStream object is used in the request.</p>
</li>
</ol>
<h3 id="heading-preflighted-requests">Preflighted requests</h3>
<p>Preflighted request is a type of request which sends an HTTP request by the OPTIONS method to the resource on the other domain, in order to determine whether the actual request is safe to send. Cross-site requests are preflighted like this since they may have implications to user data. It is evident from the screenshots above.</p>
<p>For requests like PUT, DELETE, PATCH etc, preflight requests are sent.</p>
<p>Below flowchart summarises really well how it works.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*cYI52Rb-fWjSFiQPoCF9pQ.png" alt="Image" width="1534" height="1770" loading="lazy"></p>
<p><em>Image Courtesy html5rocks</em></p>
<p>This flowchart opens up a door to a whole new knowledge. Couldn’t help but appreciate how good it is!</p>
<blockquote>
<p><em>Strangely enough even GET request was observed to have preflights which for my case was due to presence of custom header Authorization, which can be seen from the screenshot below</em></p>
</blockquote>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*W7g8e0J9fwocmwX_Ce6VWA.png" alt="Image" width="1600" height="625" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*JgwOpH3t9oTrL8Q_UM01mw.png" alt="Image" width="1600" height="712" loading="lazy"></p>
<h4 id="heading-is-preflight-request-bad">Is Preflight request bad?</h4>
<p>It is a small request without a body, but I always felt it as a bother. It is still a request, and each request is a cost, no matter how small that request is, so I definitely recommend to try and avoid having such cases.</p>
<h4 id="heading-how-do-we-avoid-it">How do we avoid it?</h4>
<p>Well the easiest solution is avoid CORS, try to keep our resources and APIs in the same domain. It is really that simple.</p>
<h4 id="heading-conclusion">Conclusion</h4>
<p>It is always good to be armed with knowledge of how requests work. Even if the cost is very low, it still matters. Saving small requests can make our application really fast in the long run. Well I believe in the future, which is fast and furious.</p>
<blockquote>
<p><em>Follow me on</em> <a target="_blank" href="https://twitter.com/daslusan"><strong>twitter</strong></a> to get more updates regarding new articles and to stay updated in latest frontend developments. Also <strong>share</strong> this article on twitter to help others know about it. Sharing is caring <strong>^_^</strong></p>
</blockquote>
<h3 id="heading-some-helpful-resources">Some helpful resources</h3>
<p>Below are some of the links that inspired this article</p>
<ol>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS">https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS</a></p>
</li>
<li><p><a target="_blank" href="https://stackoverflow.com/questions/24704638/options-request-makes-application-2x-slower">https://stackoverflow.com/questions/24704638/options-request-makes-application-2x-slower</a></p>
</li>
<li><p><a target="_blank" href="https://stackoverflow.com/questions/29954037/why-is-an-options-request-sent-and-can-i-disable-it/29954326">https://stackoverflow.com/questions/29954037/why-is-an-options-request-sent-and-can-i-disable-it/29954326</a></p>
</li>
<li><p><a target="_blank" href="https://www.html5rocks.com/en/tutorials/cors/">https://www.html5rocks.com/en/tutorials/cors/</a></p>
</li>
</ol>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ JavaScript: The Fun Parts ]]>
                </title>
                <description>
                    <![CDATA[ By Mohammad Kermani It was the first years of the modern web. People were getting sick of waiting minutes for their connection to transfer the 8 bits of data telling them “Sorry, your password must contain an & or a %. Please try again.” They wanted ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-the-fun-parts/</link>
                <guid isPermaLink="false">66d45f68f855545810e93485</guid>
                
                    <category>
                        <![CDATA[ fun ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Inspiration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ TypeScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 31 May 2019 20:03:46 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/05/1_ANQKBQyZKcn6AtDfld4DcA-1-.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Mohammad Kermani</p>
<p>It was the first years of the modern web. People were getting sick of waiting minutes for their connection to transfer the 8 bits of data telling them <em>“Sorry, your password must contain an &amp; or a %. Please try again.”</em> They wanted more instantaneous feedback. Something that felt more like a desktop application.</p>
<p>Then finally on a rainy night in May of 1995, the great champion was born. His father, <a target="_blank" href="https://en.wikipedia.org/wiki/Brendan_Eich">Brendan Eich</a>, named him JavaScript after his successful grandfather Java.</p>
<p>(<a target="_blank" href="https://en.wikipedia.org/wiki/Karl_Benz">Karl Benz</a>,the founder of Mercedes-Benz patent, is considered the father of the first practical motorcar, and JavaScript is the main engine of all browsers. This is what Brendan would look like if we called him the Benz of the web ?)</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/05/1_nY30Ve4cYfWJJKod9zjckw-1-.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>Mr. Eich, father of the champion</em></p>
<hr>
<h3 id="heading-javascript-rise-of-an-empire">JavaScript: Rise of an empire</h3>
<p>When JavaScript came into the world, no one was thinking it would be very popular like it is today. JavaScript was a true time saver because of its browser-side validations. <strong>But what happened that caused JavaScript to grow so fast?</strong></p>
<p>Before I learn JavaScript, I used to write programs in the VB6 language. But VB6 wasn’t independent. It needed its own platform to run. One of the main reasons that JavaScript is so popular is that almost all devices have a browser. In short: JavaScript won’t limit you to a platform or type of device. You can run it on basically everything.</p>
<p>JavaScript’s progress and popularity is not a secret, but below you can see how JavaScript compares favorably with some other languages.</p>
<h4 id="heading-there-are-more-contents-on-the-web-for-javascript"><strong>There are more contents on the web for JavaScript:</strong></h4>
<p>Search engines show the number of found results below their search; here is the search result for Java and JavaScript.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/05/1_7fXn5GFBjwdOmtHBAj9rgQ-1-.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>Google result for searching Java and JavaScript</em></p>
<h4 id="heading-there-are-more-people-who-are-learning-it"><strong>There are more people who are learning it:</strong></h4>
<p>Stack Overflow tags and the number of questions that were asked for any tag, it can show us the number of people who are learning the tag which is a technology; Stack Overflow tags are also a good way to check how a technology is growing and its popularity.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/05/1_VzD7WJoX9rNf5d92guDQUg-1-.jpeg" alt="Image" width="600" height="400" loading="lazy">
<em>JavaScript is the most popular tag of Stack Overflow</em></p>
<h4 id="heading-the-most-popular-language-on-github"><strong>The most popular language on GitHub:</strong></h4>
<p>According to GitHub, JavaScript is the most popular language of GitHub followed by Java, Ruby and PHP.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/05/1_h2WkxOdYLcj4u3cmx3gxRA-1-.jpeg" alt="Image" width="600" height="400" loading="lazy"></p>
<h4 id="heading-javascript-is-already-the-most-popular-but-it-is-still-growing-fast"><strong>JavaScript is already the most popular but it is still growing fast</strong></h4>
<p>Stack Overflow runs a survey every year, and this year’s survey result is very interesting and there are good things to learn from it. The picture below from the survey result shows that JavaScript is growing faster than before.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/05/1_f-nN7w-eapXm_SVZWtIerw-1-.png" alt="Image" width="600" height="400" loading="lazy">
_Source: [Stack Overflow developer survey 2017](http://stackoverflow.com/insights/survey/2017/?utm_source=so-owned&amp;utm_medium=hero&amp;utm_campaign=dev-survey-2017&amp;utm<em>content=hero-questions#technology-languages-over-time" rel="noopener nofollow)</em></p>
<h3 id="heading-javascript-is-still-misunderstood">JavaScript is still misunderstood</h3>
<p>All programming languages have their own rules, syntaxes and concepts, and each of them were made to be perfect in something, and none of them are completely perfect, we should not expect a programming language to be jack of all trades and master of none. That’s the reason many projects should chose different programming languages to bring better performance for each parts of their software.</p>
<p>It’s fair to say that JavaScript does not have some concepts that other programming languages have but it might come back to language design goals. One of the currently recognized problems with JavaScript is a lack of static typings that might cause problems in larger applications. That is why elegant <a target="_blank" href="https://github.com/Microsoft/TypeScript">TypeScript</a> was created.</p>
<blockquote>
<p><em>JavaScript was never really engineered to write large applications, it was in fact invented in about 3 weeks, in the mid 90s as a quick response to Java…, For Brendan Eich build it in 3 weeks and for having only 3 weeks, he actually did a fantasticjob, JavaScript was perhaps intended for a 100 or maybe up to a 1,000 lines of code, and now with regularity people are building 100,000 line apps, if not million lines apps. —</em><a target="_blank" href="https://en.wikipedia.org/wiki/Anders_Hejlsberg"><em><strong>Anders Hejlsberg</strong></em></a><strong><em>, known for TypeScript, Turbo Pascal, Delphi, and lead architect of C#</em></strong> <em>(source:</em> <a target="_blank" href="http://video.ch9.ms/ch9/4ae3/062c336d-9cf0-498f-ae9a-582b87954ae3/B881_mid.mp4"><em>this video</em></a><em>, time: 01:20)</em></p>
</blockquote>
<p>Without a doubt, JavaScript owes its progress to browsers and their support of good things such as responsive web design, WebGL, <a target="_blank" href="https://webrtc.org/">WebRTC</a> and lots of more cool things that made JavaScript more useful. Nowadays, developers are using JavaScript for game development, data visualization, mobile applications, back-end development and other fun things as well.</p>
<hr>
<h3 id="heading-motivated-to-learn-javascript-or-being-a-better-javascript-developer-lets-get-started">Motivated to learn JavaScript or being a better JavaScript developer? Let’s get started.</h3>
<p>Let’s say you already know some JavaScript or you’re a beginner. Don’t waste time and jump into your preferred IDE and start writing the codes you want.</p>
<p>The fastest way to learn is <strong>learn while doing</strong>, but there is a problem with this method. There are some tricks you don’t know or you never heard of them but you’re writing your codes without knowing them and it’s hard to learn those rules or tricks without reading them somewhere. You already know you can define a variable by using the <strong>var</strong> keyword, but maybe you did not know that if you don’t use the <strong>var</strong> keyword, the variable will be global regardless of its defined place.</p>
<p>You will eventually learn what you need to know but that is doing it the hard way. Indeed, one of the best places you can <strong>learn while doing</strong> is<a target="_blank" href="https://www.freecodecamp.com/">freeCodeCamp</a>, You can work through freeCodeCamp’s self-paced coding challenges, build projects, and earn certificates. it’s like diving into code but still knowing what you’re doing and learning tricks and rules in a fast and effective way.</p>
<h4 id="heading-the-problem-with-learning-javascript"><strong>The problem with learning JavaScript</strong></h4>
<p>There are many technologies and libraries for JavaScript that make it feel scary for beginners. There are some famous names that maybe you have never used and you hear about them constantly.</p>
<p>Some people think <em>“What’s this</em> <a target="_blank" href="https://babeljs.io/"><em>Babel</em></a> <em>thing everyone is talking about. All the famous open-source projects are using it!” Or, “Wait — should I use</em> <a target="_blank" href="http://browserify.org/"><em>Browserify</em></a> <em>or</em><a target="_blank" href="https://webpack.github.io/"><em>Webpack</em></a><em>? Where did Gulp and Grunt came from? Ahhh, another new library or framework introduced last week! I can’t learn them all ?”</em></p>
<p>Yes, you can’t and you should not learn them all immediately. Those technologies, frameworks and libraries exist to help you work smarter, faster and easier. When you find something interesting that is worthwhile to use on your project or is an answer to one of your needs, then you should go ahead and learn it with a beautiful smile on your face while remembering the English proverb <em>“necessity is the mother of invention.”</em></p>
<blockquote>
<p><em>“I’d encourage folks to remember we’re all in the same boat and our tools are here to help us. If they’re not doing that, we should get them out of the way.” — <a target="_blank" href="https://medium.com/@addyosmani">Addy Osmani</a> (<a target="_blank" href="https://medium.com/@addyosmani/totally-get-your-frustration-ea11adf237e3#.t599ja0j3">Link to his story</a>)</em></p>
</blockquote>
<hr>
<p>Finally, I would like to thank <a target="_blank" href="https://www.grammarly.com/grammar-check">Grammarly</a> because of their perfect tool, which let me write an article in English, even though I'm not a native English speaker. <a target="_blank" href="https://www.grammarly.com/grammar-check">Try it</a> even if you're a native English speaker</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to setup your ES6 environment quickly ]]>
                </title>
                <description>
                    <![CDATA[ By Dler Ari As you may know, browsers are starting to catch up with ES6. However, not everything works as smooth as expected, and this can be a time-consuming and tedious problem to solve. If something goes wrong, trying to identify if the problem li... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-install-and-run-es6-quickly-b3cb115ea3dd/</link>
                <guid isPermaLink="false">66d45e4ad14641365a0508bc</guid>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Tutorial ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sun, 25 Mar 2018 12:46:06 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*seBGHx_gW4Kkeq3Yh66cFw.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Dler Ari</p>
<p>As you may know, browsers are starting to catch up with ES6. However, not everything works as smooth as expected, and this can be a time-consuming and tedious problem to solve. If something goes wrong, trying to identify if the problem lies in the code or the browser is not an easy process.</p>
<p>But don’t worry, I’ll show you how you can quickly install and write ES6 code, and most importantly, make it compatible to all browsers that support ES5.</p>
<h4 id="heading-es5-to-es6">ES5 to ES6</h4>
<p>In order to write ES6 code, we need to install something that can compile it to ES5. We will be using, <code>Rollup</code>. It compiles small pieces of code into something larger and more complex, such as a library or application. This allows you to use OOP (object-oriented-programming) which makes your code look cleaner, structured and modular, along with other useful functionalities. To clarify, JS is object-oriented, but is not a <strong>class-based</strong> object-oriented language like Java, C++, C#, etc, until the release of ES6.</p>
<p>Otherwise, the closest you can come to OOP in regards to <strong>include classes</strong> with ES5 is to use IIFE (Immediately Invoked Function Expression), or install external libraries. But why rely on external resources when you have a core-language that supports the OOP paradigm? Many of the most widely used programming languages already support it (like C++, Java, C# and PHP).</p>
<h4 id="heading-why-es6">Why ES6?</h4>
<p>Personally, I use it because it allows me to organize my code into separate files, which makes it easier to scale and maintain the code.</p>
<p>For instance, in my HTML, I have one <code>script</code> that loads <code>main.js</code>, and inside <code>main.js</code>, I load multiple <code>JS</code> files using <code>import</code> and <code>export</code> statements. Instead of having multiple scripts in my HTML file, I only need one (less code).</p>
<h4 id="heading-prerequisites">Prerequisites</h4>
<ul>
<li>Linux or macOS (Debian based)</li>
<li>NPM (package manager) installed</li>
<li>Basic CLI knowledge</li>
</ul>
<h3 id="heading-step-one-install-rollup">Step one: Install Rollup</h3>
<p>In order to use <code>Rollup</code> we must install it globally. Remember to use <code>sudo</code>. This allows you to access <code>Rollup</code> commands in whatever project you work with.</p>
<h3 id="heading-step-two-file-structure">Step two: File structure</h3>
<p>After you’ve installed <code>Rollup</code> globally, the next step is to setup up the folder structure and create two folders <code>src</code> and <code>dest</code> inside your project. In addition, create <code>index.html</code>.</p>
<ul>
<li><code>src</code> → ES6 files (Where you’ll write the code)</li>
<li><code>dest</code> → Generates an ES5 (Compiled versions of ES6)</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/rr27ThFPxfFLGvHax9OptosBHLWBhRhXumoa" alt="Image" width="325" height="193" loading="lazy">
<em>Project ES6 folder structure</em></p>
<p>Keep in mind, the <code>bundle.js</code> file is auto-generated when the <code>Rollup</code> command is executed. We will talk about this later.</p>
<h3 id="heading-step-three-create-a-configuration-file">Step three: Create a configuration file</h3>
<p>Create a new file and name it <code>rollup.config.js</code> . Then add this code:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QYC3JcSz2eunCjok-wZVevaKxAVJHIkhJ-bP" alt="Image" width="800" height="263" loading="lazy">
<em>Configuration file for rollup.config.js</em></p>
<p>Make sure that the <code>input</code> and <code>output</code> source path is correct with your folder structure, and that this file is placed in the main folder.</p>
<h3 id="heading-step-four-load-the-script-file-in-html">Step four: Load the script file in HTML</h3>
<p>We are almost ready, but first we need to link to the right source file in our HTML template. This will load the ES5 file which is compiled from ES6.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/2s5VhC9I2wYk1AaXriy6ybxXYQliIXSupBhs" alt="Image" width="800" height="351" loading="lazy">
<em>HTML template loads ES6 script</em></p>
<h3 id="heading-step-five-setup-js-files">Step five: Setup JS files</h3>
<p>In order to verify that the <code>Rollup</code> command works, we need to setup a simple OOP structure. We will create a <code>car.js</code> class, and <code>default export</code> it to <code>main.js</code>.</p>
<p>Keep in mind that this file exports a new instance of the <code>car.js</code> class, and this allows to access the methods directly rather than writing <code>const car = new Car()</code> in the <code>main.js</code> class.</p>
<p>Since I am a lazy software engineer, dealing with a few extra characters of code is time-consuming :)</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/5aKZz1Ppg7yzGGIPj16zbAqnSY7VDA7gpPzo" alt="Image" width="800" height="285" loading="lazy">
<em>car.js class</em></p>
<p>Next, import the <code>car.js</code> class to <code>main.js</code> in order to access the method’s <code>type()</code>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/TAsHat7IhM9h1BgK-rdFNv1pHxCB0MPyTSv4" alt="Image" width="800" height="197" loading="lazy">
<em>main.js class</em></p>
<h3 id="heading-step-six-compile-es6-to-es5">Step six: Compile ES6 to ES5</h3>
<p>To execute the configuration file we’ve created, run this command <code>$ rollup -c</code> or <code>$ rollup --config</code> — both are the same.</p>
<p>After running one of the commands, open <code>index.html</code> through a browser, then open inspect (<code>ctrl + shift + I</code>) on the browser, and go to <code>console</code>. If you see the text <code>"Tesla Model S"</code>, it means everything worked successfully.</p>
<p>Keep in mind that every time you make changes with ES6 files, you must update it by running the command.</p>
<h3 id="heading-optional">Optional</h3>
<p>Since you have installed <code>Rollup</code> globally, you can compile ES6 without needing to have the file <code>rollup.config.js</code> . It does exactly the same thing:</p>
<p><code>$ rollup src/main.js — o dest/bundle.js — f iife</code></p>
<p>Personally, I would recommend running <code>$ rollup -c</code> as shown in step six since there is less code required. Remember that you must have the file <code>rollup.config.js</code> included when running this command.</p>
<p><em>If you found this short installation approach setup for ES6 useful, please comment and clap. It’s good karma.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Why Progressive Web Apps Are The Future Of Web Development ]]>
                </title>
                <description>
                    <![CDATA[ By Tushar Agrawal “The key is to embrace disruption and change early. Don’t react to it decades later. You can’t fight innovation.” — Ryan Kavanaugh Lately, there’s been a lot of buzz around PWAs with many claiming it to be future of web developmen... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/why-progressive-web-apps-are-the-future-of-web-development-13db7dd5f640/</link>
                <guid isPermaLink="false">66c36705b737bb2ce7073219</guid>
                
                    <category>
                        <![CDATA[ Apps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ PWA ]]>
                    </category>
                
                    <category>
                        <![CDATA[ web ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 05 Dec 2017 18:20:16 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*oc4pOoEeR_QMrCA6LkF5Kw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Tushar Agrawal</p>
<blockquote>
<p>“The key is to embrace disruption and change early. Don’t react to it decades later. You can’t fight innovation.” — Ryan Kavanaugh</p>
</blockquote>
<p>Lately, there’s been a lot of buzz around PWAs with many claiming it to be future of web development, especially in terms of mobile devices. At its core, a Progressive Web App (PWA) is simply a web application that uses modern web techniques to deliver a native app-like experience to users. These are web applications with progressive enhancement to implement features like caching, background sync, and push notifications.</p>
<p>Even though <a target="_blank" href="https://developers.google.com/web/progressive-web-apps/">PWAs</a> have been around for more than two years now, the response is quite underwhelming. Few big players have adopted this philosophy but most haven’t actually embraced it very much. Chrome and Mozilla are perhaps the best browsers to test out your PWAs as Apple is yet to get into this stuff.</p>
<h3 id="heading-pwa-is-it-really-good">PWA — Is it really good ?</h3>
<p>On one hand, we have native apps that are undoubtedly fast and efficient in most of the cases. On the other hand, there are websites that are kinda slow and with the connectivity issues, it only gets worse.</p>
<p>Accelerated Mobile Pages Project (<a target="_blank" href="https://www.ampproject.org/">AMP</a>) spearheaded by Twitter and Google was launched in 2016 to solve those slow connection issues only. PWAs work flawlessly in all the possible scenarios. With a good connection, there is never a problem. The problem is when we have no connection and we are greeted with the error page.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*0DOKUYA7bHE9COGpJw5q0Q.png" alt="Image" width="620" height="224" loading="lazy"></p>
<p>But this can become most annoying if we have a slow connection. The page seems to be loading and all we see is a blank screen. We just wait, wait and wait but the page never seems to load. This is where PWA comes to our rescue. The best part about PWAs — you get the best user experience possible in slow connectivity as well as no connectivity (yep , you read it right..).</p>
<h3 id="heading-why-it-makes-sense-to-use-pwa">Why it makes sense to use PWA</h3>
<p>According to a study, an average user spends 80% of his total time on apps on only three of his apps (For me its Chrome, Quora and Medium).</p>
<p>The other apps just sit idle for most of this time consuming a precious portion of the memory. Moreover, it costs around ten times to develop an app rather than creating a website for the same. The cost can get much higher if you plan to develop and maintain separate code bases for different platforms like Android, iOS and the web.</p>
<h3 id="heading-native-app-features-that-pwas-can-use">Native App features that PWAs can use</h3>
<ul>
<li>Push notifications</li>
<li>Full Screen</li>
<li>Offline working</li>
<li>Splash screen is supported giving it a more app like feel</li>
</ul>
<p>PWAs can make use of many more such features. The above points are only to give you a hint of what PWAs are capable of. However, there are some traditional features that only native apps enjoy as of now.</p>
<h3 id="heading-native-app-features-that-pwas-cant-use-as-of-now">Native App features that PWAs can’t use as of now</h3>
<ul>
<li>No or highly restrictive access to different hardware sensors</li>
<li>Alarms</li>
<li>Phonebook Access</li>
<li>Modfiying System Settings</li>
</ul>
<p>PWAs are evolving quite fast and we can hope to see these features come to action pretty soon.</p>
<h3 id="heading-two-major-components-of-a-pwa">Two Major Components of a PWA</h3>
<p><strong>App Manifest</strong><br>It’s a JSON file that defines an app icon, how to launch the app (standalone, full-screen, in the browser etc), and any such related information. It’s located in the root of your app. A link to this file is required on each page that has to be rendered.</p>
<p>It is added in the head section of the HTML page:<br><code>&lt;link rel=”manifest" href="/manifest.jso</code>n"&gt;</p>
<p><strong>Service Worker</strong><br>Service worker is where most of the magic of happens. Its nothing but JavaScript code that acts as programmable proxies solely responsible for intercepting and responding to network requests. Since it acts as a proxy and can be easily programmable, the application must be served over HTTPS to keep the data secure.</p>
<p>Its worth noting that the service worker caches the actual response, including all HTTP headers, rather than just the response data. This means that your application can simply make network requests and process the response without any specific code to handle the cache.</p>
<h3 id="heading-how-do-i-get-started">How do I get started?</h3>
<p>The best thing about getting started is that it’s quite easier than it seems. In fact, it’s very much possible to take an existing site and convert into a PWA. I highly suggest you watch this if you intend to develop a PWA.</p>
<h4 id="heading-thanks-for-reading-if-you-liked-it-please-support-by-clapping-and-sharing-the-post">Thanks for reading! If you liked it, please support by clapping and sharing the post.</h4>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
