<?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: AmitThakur11</title>
    <description>The latest articles on DEV Community by AmitThakur11 (@amitthakur11).</description>
    <link>https://dev.to/amitthakur11</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%2F555299%2Fc71c41a3-d15f-45bc-8a6e-4abd2e935a58.png</url>
      <title>DEV Community: AmitThakur11</title>
      <link>https://dev.to/amitthakur11</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amitthakur11"/>
    <language>en</language>
    <item>
      <title>Reconciliation and Virtual DOM in React</title>
      <dc:creator>AmitThakur11</dc:creator>
      <pubDate>Sat, 08 Jan 2022 08:24:39 +0000</pubDate>
      <link>https://dev.to/amitthakur11/reconciliation-and-virtual-dom-in-react-h69</link>
      <guid>https://dev.to/amitthakur11/reconciliation-and-virtual-dom-in-react-h69</guid>
      <description>&lt;h1&gt;
  
  
  What is React?
&lt;/h1&gt;

&lt;p&gt;It is a JavaScript library for building user interfaces, developed by Facebook. It's often referred to as a framework but it's a library only React is not enough to complete a project. Developers need extra tools like redux, react-router, jest, etc. &lt;/p&gt;

&lt;p&gt;If you know about MVC( Model View Controller) architecture, here Facebook has its own refined and enhanced MVC architecture known as Flux, where React is the 'V'.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;'V'&lt;/strong&gt; in MVC
&lt;/h1&gt;

&lt;p&gt;Flux  has four components : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Action&lt;/li&gt;
&lt;li&gt;Dispatcher&lt;/li&gt;
&lt;li&gt;Store&lt;/li&gt;
&lt;li&gt;View&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.clariontech.com%2Fhs-fs%2Fhubfs%2FImage2-61.png%3Fwidth%3D513%26name%3DImage2-61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.clariontech.com%2Fhs-fs%2Fhubfs%2FImage2-61.png%3Fwidth%3D513%26name%3DImage2-61.png" alt="flux"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As we can see in the above diagram. Here React is the &lt;strong&gt;View&lt;/strong&gt;. When a user interacts with the app, the view creates actions. These actions produce new data and send it to the dispatcher. The dispatcher then dispatches these action results to the store. Store update the state and send an update to the view. That's how Flux architecture works.&lt;/p&gt;

&lt;h1&gt;
  
  
  Components
&lt;/h1&gt;

&lt;p&gt;Component(a reusable piece of HTML code) is the heart of React. A component is a small feature that makes up a piece of the user interface. Each component is independent, reusable, and isolated. For eg.&lt;br&gt;
Is it possible to write same piece of code again and again for different data? In e-commerce sites, there are product cards providing information about the product.  By using components,  we can write a piece of code and reuse it for different data.&lt;/p&gt;
&lt;h1&gt;
  
  
  Virtual DOM
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641618125750%2F53dLUnsQ1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641618125750%2F53dLUnsQ1.png" alt="vdomobject.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So basically when you write JSX, it gets transpiled into old js by babel or other compilers. It invokes the React.createElement() function with some parameters as per your component and returns a plain JS object that is kept in memory known as virtual DOM.&lt;/p&gt;

&lt;p&gt;When the state change, the virtual DOM get updated not the actual DOM. Updating Virtual DOM is very fast as well as cheap as compared to real DOM. React differentiate Virtual DOM with the snapshot of Virtual DOM before the update and this is done by diffing algorithm and finding out the changes after state update. When rendering the updates to the actual DOM, It doesn't render the entire  DOM. There are certain optimization techniques that are used to optimize the rendering which comes under the concept known as &lt;strong&gt;reconciliation&lt;/strong&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Reconciliation process
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641629515494%2FrsAhTamHf.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641629515494%2FrsAhTamHf.jpeg" alt="recociliation.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Diffing comes under reconciliation. Based on some assumptions DOM is updated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Two elements of different types will produce different trees.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#before change
&amp;lt;div&amp;gt;
     &amp;lt;h1&amp;gt;hello&amp;lt;/h1&amp;gt;
&amp;lt;/div&amp;gt;

#after change
&amp;lt;div&amp;gt;
     &amp;lt;p&amp;gt;hello&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In the above code, React will rebuild the tree inside div from scratch and all component instances in the old tree are destroyed with their current state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#before change
&amp;lt;div className ="before"&amp;gt;
     &amp;lt;h1&amp;gt;hello&amp;lt;/h1&amp;gt;
&amp;lt;/div&amp;gt;

#after change
&amp;lt;div className ="after" &amp;gt;
     &amp;lt;h1&amp;gt;hello&amp;lt;/h1&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;in the above code, we have two elements of the same type but different attributes, here only attribute updated,  instance, and state remain the same.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;When we have a list of child elements often changes, we should provide a unique "key" as a prop.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Key provides a unique identity to the elements and helps React to differentiate between them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ol&amp;gt;
     &amp;lt;li key ="one"&amp;gt;one&amp;lt;/li&amp;gt;
     &amp;lt;li key ="two"&amp;gt;two&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key helps in differentiating elements and keeping a record of changes and updating only those changes instead of rebuilding the whole tree.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>what is "this"</title>
      <dc:creator>AmitThakur11</dc:creator>
      <pubDate>Tue, 14 Sep 2021 12:24:39 +0000</pubDate>
      <link>https://dev.to/amitthakur11/what-is-this-3lko</link>
      <guid>https://dev.to/amitthakur11/what-is-this-3lko</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X0hNnhgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3w4hi7ur9yxa87gmwd8.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X0hNnhgL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3w4hi7ur9yxa87gmwd8.gif" alt="Alt Text" width="500" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;"this" is very confusing i know , but we will try our best to grab "this" .&lt;/p&gt;

&lt;p&gt;so what is "this" actually means .&lt;/p&gt;

&lt;p&gt;this represents an object that executes the current function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Dsa6ZrEW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3s4vdkejnqvvm4yt2f9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Dsa6ZrEW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a3s4vdkejnqvvm4yt2f9.png" alt="image" width="628" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;window is the global object in case of javascript, its name defer with the resp to language for eg. in Nodejs , it is called global.&lt;/p&gt;

&lt;p&gt;so, when we type window in console of our browser , we will get a object having all global JavaScript objects, functions, and variables.&lt;/p&gt;

&lt;p&gt;Even the document object is a property of the window object.&lt;/p&gt;

&lt;p&gt;you can read more about window later , but now we have to discuss about This . as you have seen that previous code, after typing window we get a object which is the same as we get when we type this , so why we get the result ? bcz as per defination , this refers to the object it belongs to.&lt;/p&gt;

&lt;p&gt;The JavaScript this has different values depending on where it is used and how the code is written . so we will discuss this on different places and then observe its action.&lt;/p&gt;

&lt;p&gt;First case : Only this&lt;/p&gt;

&lt;p&gt;when we write only this it means it refer to the global object we have seen previously.&lt;/p&gt;

&lt;p&gt;Second case : Inside Object&lt;/p&gt;

&lt;p&gt;we have create a object name as username which has a variables firstname , lastname and a function fullname .&lt;/p&gt;

&lt;p&gt;inside fullname function we console this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B8-nAVYJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkdb1e2hfssax0o7dtsl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B8-nAVYJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rkdb1e2hfssax0o7dtsl.png" alt="image" width="801" height="399"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Output :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E71gVqOJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n5sqr15we7ofiha1yn9j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E71gVqOJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n5sqr15we7ofiha1yn9j.png" alt="image" width="733" height="217"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this example , we can see inside username object we have a member function "fullname" which is console logging this . In the console we can see here this represent the object that execute cuurent function , that is username . let's see what happen if we use fat arrow function instead of normal function .&lt;/p&gt;

&lt;p&gt;"this" in Fat arrow function&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nK_xJEHA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1thpcs1i8zer76hqmad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nK_xJEHA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c1thpcs1i8zer76hqmad.png" alt="image" width="710" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8JaxVkuE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ybwpyxu6tf4tw74mnui.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8JaxVkuE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ybwpyxu6tf4tw74mnui.png" alt="image" width="710" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;so why we got "code waala" as a output and now this is refering to window object instead of username object , why this is happening when everything is going good .&lt;/p&gt;

&lt;p&gt;The thing is that arrow function deals with this keyword in a different way , They don’t define their own context since they doesn’t have its own this context. They inherit that from the parent scope whenever you call them whereas regular function takes the this context of the object under which function isexecuting.&lt;/p&gt;

&lt;p&gt;so when arrow function is called it will take this object from its parent , in our case the parent is window because it is calling in window object.&lt;/p&gt;

&lt;p&gt;Third case : constructor function&lt;/p&gt;

&lt;p&gt;so what are contruction functions ? constructor functions doesnt have any value , they are designed to create new objects .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6q4OPsJR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64tm6n7s1oszlhn6hwe6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6q4OPsJR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64tm6n7s1oszlhn6hwe6.png" alt="image" width="710" height="437"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MknaGxb8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smjwssctlgd7i63gu8yo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MknaGxb8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smjwssctlgd7i63gu8yo.png" alt="image" width="710" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code , we can see we have created a constructor function username . and from that constructor function we have create two username user1 &amp;amp; user2 .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C2l6OR-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3nswx3nnms04qgqmr6nt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C2l6OR-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3nswx3nnms04qgqmr6nt.png" alt="image" width="710" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In case of user1 we got a output "code waala" and this is refering to username object and same for user2 .&lt;/p&gt;

&lt;p&gt;but we have covered that member function take this context of the object which is executing them, in case of constructor function this represents to the newly create object as seen in output.&lt;/p&gt;

&lt;p&gt;Hope you found something useful..&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to add a pre-loader in your website.</title>
      <dc:creator>AmitThakur11</dc:creator>
      <pubDate>Thu, 07 Jan 2021 10:51:41 +0000</pubDate>
      <link>https://dev.to/amitthakur11/how-to-add-a-pre-loader-in-your-website-140i</link>
      <guid>https://dev.to/amitthakur11/how-to-add-a-pre-loader-in-your-website-140i</guid>
      <description>&lt;br&gt;


&lt;h4&gt;PRE-LOADER&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffk3smrzna1vieidxaawn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffk3smrzna1vieidxaawn.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;


A &lt;b&gt;preloader&lt;/b&gt; — or what some call a loading screen — is the what you see on some sites before the main content of the web page is loaded.Their main purpose is to entertain site visitors while the actual content of the page is still loading in the background.

&lt;h3&gt;&lt;b&gt;Follow these steps to add a pre-loader.&lt;/b&gt;&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;STEP 1 :&lt;/b&gt; Include a &lt;b&gt;DIV&lt;/b&gt; tag in the begining of a body tag and give the tag a Class or Id whatever its on you. &lt;br&gt;&lt;b&gt;for eg: id = "loading". &lt;/b&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0l8hmudrl0hqpyjzld4t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0l8hmudrl0hqpyjzld4t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;


&lt;p&gt;&lt;b&gt;STEP 2 :&lt;/b&gt; Now link a css file to your HTML file.&lt;br&gt;See the code below. Here we add few styling to the id "loading". &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feaomlei4l0ulc4t9px77.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Feaomlei4l0ulc4t9px77.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;b&gt;Position    :&lt;/b&gt;An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Width       :&lt;/b&gt;Set width to 100% so  your pre-loader will cover entire screen.&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Height      :&lt;/b&gt; Set height to 100vh(100% of the viewport height.)&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Background  :&lt;/b&gt;Here in background we will use different attributes like 
&lt;b&gt;#fff&lt;/b&gt;("white"color you can use whatever color),
&lt;b&gt;url&lt;/b&gt;(give the gif link which you want to use as a loader.),&lt;b&gt;no-repeat&lt;/b&gt;(repeatation of gif will be cornered),&lt;b&gt;center&lt;/b&gt;(To get pre-loader in center accn to viewport.).
  &lt;/li&gt;
&lt;li&gt;
&lt;b&gt;z-index     :&lt;/b&gt;The z-index property specifies the stack order of an element.An element with greater stack order is always in front of an element with a lower stack order.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;b&gt;STEP 3 :(a)&lt;/b&gt;Now add a &lt;b&gt;onload&lt;/b&gt; event in a body tag so it will Execute a JavaScript immediately after a body content  has been loaded:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbwho6zosy19t9sv5v3p2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbwho6zosy19t9sv5v3p2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;b&gt;(b)&lt;/b&gt;Now add a &lt;b&gt;script tag&lt;/b&gt; inside &lt;b&gt;Body tag&lt;/b&gt;. Then create variable which we will use to manipulate our 'loading' id. and set the display odf loading to none when the content of webpage load. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fd96wuus1mh9r46retdbl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fd96wuus1mh9r46retdbl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;


&lt;p&gt;--Now your pre-loader is ready.&lt;/p&gt;



</description>
      <category>css</category>
      <category>html</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
