<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AnuraG Singh</title>
    <description>The latest articles on DEV Community by AnuraG Singh (@anurag_singh_2jz).</description>
    <link>https://dev.to/anurag_singh_2jz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1725215%2F0332453f-200a-44ff-a081-7868282f98d6.jpg</url>
      <title>DEV Community: AnuraG Singh</title>
      <link>https://dev.to/anurag_singh_2jz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anurag_singh_2jz"/>
    <language>en</language>
    <item>
      <title>benefits of parcel as a bundler</title>
      <dc:creator>AnuraG Singh</dc:creator>
      <pubDate>Wed, 10 Jul 2024 19:12:37 +0000</pubDate>
      <link>https://dev.to/anurag_singh_2jz/benefits-of-parcel-as-a-bundler-1fbi</link>
      <guid>https://dev.to/anurag_singh_2jz/benefits-of-parcel-as-a-bundler-1fbi</guid>
      <description>&lt;h2&gt;
  
  
  benefits of parcel
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;dev tools&lt;/li&gt;
&lt;li&gt;HMR - hot modules replacement  
---&amp;gt;&amp;gt; how - by using file watching algorithms made in c++ which keep track of your code and as soon as 
    you try to save the file it refreshes the server with new code&lt;/li&gt;
&lt;li&gt;local server &lt;a href="http://localhost:1234" rel="noopener noreferrer"&gt;http://localhost:1234&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt; cache memory mang. ---&amp;gt; makes its fast&lt;/li&gt;
&lt;li&gt;image optimization&lt;/li&gt;
&lt;li&gt;compresses the file &lt;/li&gt;
&lt;li&gt;bundling&lt;/li&gt;
&lt;li&gt;content hashing&lt;/li&gt;
&lt;li&gt;differential bundling &lt;strong&gt;babel&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;can also run on ssl https&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;tree shaking ---&amp;gt; removing the extra code or function which are not used &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;content hasing :&lt;/strong&gt; -Content hashing in Parcel involves generating unique SHA-256 hashes for each file based on its content. Before deploying the application, Parcel compares these hashes with those stored in its cache directory ( .parcel-cache). If a file's hash matches its cached version, Parcel uses the cached file, avoiding unnecessary rebuilds and optimizing deployment speed. When a file's content changes, its hash updates, prompting Parcel to rebuild only the modified files and update them on the server. This approach not only improves build performance by reusing unchanged files but also ensures that browsers receive updated content reliably through unique filenames based on file hashes, preventing caching issues during deployment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;hmr in detail&lt;/strong&gt; - so basically when file is modified i.e its hash is now different that of older version the modified file is only updated in the browser and all the other file whose hash are same of older hash uses the .parcel-cache file which reduce the time and avoid the rebuilding the whole application from scratch and this all thing is triggered every time when the programmer save the file &amp;amp;&amp;amp; the browser is running that application (live) &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;differential bundling :&lt;/strong&gt; since babel is used for bundling in parcel -- it perform several task &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;babel convert the es6+ js code into the es5 code which necessary for you application to run in older browser &lt;/li&gt;
&lt;li&gt;It convert the jsx code of react into the js code (jsx into js object (ast)) as we all know browser's v8 engine is unable to understant the jsx code &lt;/li&gt;
&lt;li&gt;It also convert typescript in JavaScript as TS is superset of js that add static type to js &lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>systemdesign</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>npm Overview and Key Concepts</title>
      <dc:creator>AnuraG Singh</dc:creator>
      <pubDate>Mon, 08 Jul 2024 20:27:44 +0000</pubDate>
      <link>https://dev.to/anurag_singh_2jz/npm-overview-and-key-concepts-2m1a</link>
      <guid>https://dev.to/anurag_singh_2jz/npm-overview-and-key-concepts-2m1a</guid>
      <description>&lt;p&gt;npm, short for Node Package Manager, is a package manager for JavaScript and the default package manager for the Node.js runtime environment. It helps developers manage dependencies in their projects and provides a vast registry of reusable code packages.&lt;br&gt;
&lt;strong&gt;Basically it is a configuration for npm&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of npm
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Package Management:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Install, update, and uninstall packages (libraries or modules).&lt;/li&gt;
&lt;li&gt;Manage dependencies required for your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Versioning:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Specify the version of a package to ensure compatibility and stability.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Script Running:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Define and run custom scripts for various development tasks, such as &lt;br&gt;
testing, building, and deploying, through the scripts section in &lt;br&gt;
package.json. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Custom script can be run using &lt;code&gt;npm run &amp;lt;script-name&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Dependency Management:&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Automatically handle dependency conflicts and ensure that the correct &lt;br&gt;
versions of dependencies are used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Different types of dependencies can be specified in the package.json &lt;br&gt;
file, such as regular dependencies, devDependencies, peerDependencies, &lt;br&gt;
and optionalDependencies.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Package-lock.json
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It keeps the track of all the dependency's version in  hash form(SHA) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The package-lock.json file ensures consistency across different environments by locking the exact versions of all installed dependencies. It helps avoid dependency conflicts and ensures that the correct versions of dependencies are used. Basically avoids version mis-match.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;for eg your project is buid using react 18 and if the project is setup on any other pc with older version of react pre-installed let say react 17 then it will hampers the proper functioning of the code or your project , Here package-lock.json comes into role i.e when ever you deploy you project into any other environment it will instantly install the react 18 regardless of pre-installed react 17 &lt;/p&gt;

&lt;h2&gt;
  
  
  package.json Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "my-project", //app or project name
  "version": "1.0.0", // apps version 
  "description": "A sample project",
  "main": "index.js", 
  "scripts": {
    "start": "node index.js", // npm run start will run index.js
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1", // use jest
    "build": "webpack --config webpack.config.js",
    "lint": "eslint .", //catches error
    "deploy": "npm run build &amp;amp;&amp;amp; firebase deploy" //builds and deploy onto //firebase
  },
  "dependencies": {
    "express": "^4.17.1",
    "react" : "^18.0"
  },
  "devDependencies": {
    "eslint": "^7.11.0",
    "webpack": "^4.44.2"
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>npm</category>
    </item>
    <item>
      <title>Manual DOM Rendering with JavaScript vs. React's Virtual DOM</title>
      <dc:creator>AnuraG Singh</dc:creator>
      <pubDate>Wed, 03 Jul 2024 17:43:12 +0000</pubDate>
      <link>https://dev.to/anurag_singh_2jz/manual-dom-rendering-with-javascript-vs-reacts-virtual-dom-2d5</link>
      <guid>https://dev.to/anurag_singh_2jz/manual-dom-rendering-with-javascript-vs-reacts-virtual-dom-2d5</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This documentation explains how to manually create and render DOM elements using plain JavaScript. We will cover the implementation of a custom rendering function and its comparison to how JSX is processed in React.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;creating a custom render function&lt;/strong&gt;&lt;br&gt;
we created a customRender function which takes two parameters &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;imgTag&lt;/code&gt; : object which specifies the property&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;root&lt;/code&gt; : parent element where the element is to be appended&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Inside function definition we created img tag and added attributes to it &lt;br&gt;
and in the end we appended it in the root div &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;overall we made the manually created the DOM and rendered it on the web page
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  manual insertion
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let imgtag = {
    type:'img',
    props:{
        src:'https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png',
        alt:'image of google'
    }
}
function IMGrender(imgtag,root){
    let div = document.createElement(imgtag.type)
    for (const key in imgtag.props) {
        if(key === "children") continue;
        div.setAttribute(key,imgtag.props[key])
    }

    root.appendChild(div)
}

IMGrender(imgtag,root)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Comparison to React
&lt;/h2&gt;

&lt;p&gt;The customRender function manually performs tasks that React handles automatically when processing JSX. React uses a virtual DOM to efficiently manage and update the actual DOM.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;here in react we can use JSX to make a component (html tags) which 
later get converted into the object like a object in a customRender
function &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Vite uses esbuild as its bundler to parse JSX code into JavaScript objects (AST - Abstract Syntax Tree).&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  using react
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react'
import ReactDOM from 'react-dom/client'
function Img(){
  return(
    &amp;lt;img src='https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png' alt='img'&amp;gt;&amp;lt;/img&amp;gt;
  )
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;The custom render function demonstrates manual DOM manipulation, where you directly create and update elements. In contrast, React abstracts these details away using JSX and the virtual DOM, which allows for more efficient updates and simpler, more declarative UI code.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
