<?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: Harshita Kanal</title>
    <description>The latest articles on DEV Community by Harshita Kanal (@harshitakanal).</description>
    <link>https://dev.to/harshitakanal</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%2F487595%2Fba249752-8d7c-4dcf-925b-e7939793fcc4.png</url>
      <title>DEV Community: Harshita Kanal</title>
      <link>https://dev.to/harshitakanal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harshitakanal"/>
    <language>en</language>
    <item>
      <title>JavaScript Module Bundlers and all that Jazz ✨</title>
      <dc:creator>Harshita Kanal</dc:creator>
      <pubDate>Sun, 26 Mar 2023 15:57:57 +0000</pubDate>
      <link>https://dev.to/harshitakanal/javascript-module-bundlers-and-all-that-jazz-3hbi</link>
      <guid>https://dev.to/harshitakanal/javascript-module-bundlers-and-all-that-jazz-3hbi</guid>
      <description>&lt;h2&gt;
  
  
  So, what is a bundler?
&lt;/h2&gt;

&lt;p&gt;A bundler is a tool that brings all your code organized into multiple files, together (bundled up!), ready to be loaded into the browser. While doing so, it generates a dependency graph of all your source code, and third-party libraries and ensures that the dependencies could be easily updated and the code is error-free. Along with this, some bundlers also come with features that help you in optimizing the performance of your app, helping you implement things like &lt;a href="https://webpack.js.org/guides/tree-shaking/"&gt;tree-shaking&lt;/a&gt;, &lt;a href="https://webpack.js.org/guides/lazy-loading/"&gt;lazy loading&lt;/a&gt;, &lt;a href="https://webpack.js.org/guides/lazy-loading/"&gt;code splitting&lt;/a&gt;, &lt;a href="https://webpack.js.org/concepts/hot-module-replacement/"&gt;hot module replacement&lt;/a&gt;, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  How was the world like before bundlers?
&lt;/h2&gt;

&lt;p&gt;Before bundlers - for a large part of the old web, people would link the JavaScript files served through a CDN directly. Let's consider jQuery as an example -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"//code.jquery.com/jquery-2.13.0.min.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;// `$` global variable available here&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This began to change when NPM came in and running &lt;code&gt;npm install&lt;/code&gt; became a quick and easy way to install dependencies. &lt;a href="https://browserify.org/"&gt;Browserify&lt;/a&gt; became the first JavaScript bundler. As its documentation says -&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;"Browsers don't have the require method defined, but Node.js does. With Browserify you can write code that uses require in the same way that you would use it in Node."&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Also, the &lt;code&gt;require()&lt;/code&gt; node method was synchronous, if we need a file that hasn't been loaded, we need to do an HTTP request, but that's asynchronous. The solution is to put all dependencies together and have the code ready in memory so that it could be used whenever needed with the &lt;code&gt;require()\&lt;/code&gt; method. Also, say you only use a single function from &lt;code&gt;lodash&lt;/code&gt;, you have to add the entire library and then squish it together. How do you tree shake the dependencies on your code? Lazy loading chunks of code can be hard to do at scale and requires a lot of manual work from the developer. JavaScript bundler would help implement exactly that.&lt;/p&gt;

&lt;p&gt;Browserify was great at bundling scripts, but what if we need to transform code - Say compile CoffeeScript to JavaScript, for this, a new group of tools for the web was born, which focussed on running code transforms. These are usually called task runners, and the most popular ones are &lt;a href="https://gruntjs.com/"&gt;Grunt&lt;/a&gt; and &lt;a href="https://gulpjs.com/"&gt;Gulp&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And then came &lt;a href="https://webpack.js.org/"&gt;Webpack&lt;/a&gt;, which attempted to give the best of both worlds and much more. It also supported bundling and transforming non-JavaScript assets, like HTML, CSS, and images. Many popular tools today like &lt;code&gt;create-react-app&lt;/code&gt; use Webpack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some popular bundlers today
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Webpack
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://webpack.js.org/"&gt;Webpack&lt;/a&gt; is a &lt;em&gt;static module bundler&lt;/em&gt; for modern JavaScript applications. On processing your application - Webpack internally builds a &lt;a href="https://webpack.js.org/concepts/dependency-graph/"&gt;dependency graph&lt;/a&gt; from one or more &lt;em&gt;entry points&lt;/em&gt; and then combines every module your project needs into one or more &lt;em&gt;bundles&lt;/em&gt;, which are static assets from which content is served.&lt;/p&gt;

&lt;p&gt;Some of its features include -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hot module replacement&lt;/strong&gt; - exchanges, adds, or removes &lt;a href="https://webpack.js.org/concepts/modules/"&gt;modules&lt;/a&gt; while an application is running, without a full reload. Thus, saving you time 😁&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Splitting&lt;/strong&gt; - allows you to split your code into various bundles which can then be loaded on demand or in parallel. It can be used to achieve smaller bundles and control resource load prioritization which, if used correctly, can have a major impact on load time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Tree-shaking&lt;/strong&gt; - A term commonly used in JavaScript for dead code elimination, The webpack 2 release came with built-in support for ES2015 modules as well as unused module export detection.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Parcel
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://parceljs.org/"&gt;Parcel&lt;/a&gt; is a popular zero configuration build tool for the web. Some of its popular features include -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Native performance&lt;/strong&gt; - Parcel's JavaScript compiler, CSS transformer, and source maps implementation are written in Rust for maximum performance. It builds the code in parallel using worker threads, utilizing all of the cores on the machine. Everything is cached - ensuring that the same code isn't built multiple times.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lazy dev builds -&lt;/strong&gt; In development, Parcel can defer building files until they are requested in the browser.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other popular build tools include &lt;a href="https://vitejs.dev/guide/why.html"&gt;Vite.js&lt;/a&gt;, &lt;a href="https://browserify.org/"&gt;Browserify&lt;/a&gt;, &lt;a href="https://rollupjs.org/"&gt;Rollup - The bundler behind vite&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL: DR;
&lt;/h2&gt;

&lt;p&gt;In this article, we learned about bundlers, their background, the world before them and got introduced to some popular bundlers. So, dive deep in and explore what works for your projects the best ✨&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>Decoding JS: Polyfills and Transpilers</title>
      <dc:creator>Harshita Kanal</dc:creator>
      <pubDate>Sat, 11 Feb 2023 20:28:18 +0000</pubDate>
      <link>https://dev.to/harshitakanal/decoding-js-polyfills-and-transpilers-3b87</link>
      <guid>https://dev.to/harshitakanal/decoding-js-polyfills-and-transpilers-3b87</guid>
      <description>&lt;h3&gt;
  
  
  Polyfills
&lt;/h3&gt;

&lt;p&gt;A polyfill is a piece of code, in JavaScript that is used to provide some functionality in a browser, that does not natively support it. They are written to replicate an API that is available in some browsers, for those who don't have it or don't have it completely working.&lt;/p&gt;

&lt;p&gt;Sometimes, they are also used to solve the issue of different browsers implementing the same feature in different ways and giving JavaScript a standard-compliant way of accessing the feature - this reason for poly-filling was prevalent in the old IE6 and Netscape days, where each browser used to implement different features differently.&lt;/p&gt;

&lt;p&gt;Simply put, one can imagine a polyfill as a common paste which can be used to fill holes and cracks to smooth out any defects in a wall. In the UK there is a popular brand name for this paste which is called &lt;strong&gt;“Polyfilla”.&lt;/strong&gt; The JavaScript Polyfill fills in for the same pieces of missing functionality across browsers. Interesting stuff!&lt;/p&gt;

&lt;h3&gt;
  
  
  Some Examples
&lt;/h3&gt;

&lt;p&gt;Modern language features, not only include operators or syntactic constructs but also functions or methods. Consider the &lt;code&gt;String.prototype.startsWith()&lt;/code&gt; method - It is used to determine if a string begins with the characters of a specified string, returning &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt; as appropriate. Example -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// startsWith(searchString)&lt;/span&gt;
&lt;span class="c1"&gt;// startsWith(searchString, position)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I am learning polyfill&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myString&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I am&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Expected output: true&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myString&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Expected output: false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Say there exists some super legacy browser, which doesn't support this method, and it would not perform as expected in this browser - to make up for it, we need to write a polyfill for this method. It would look something like this -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// If the method doesn't exist - &lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

 &lt;span class="c1"&gt;// Use a function that takes the same params, with position defaulting to 0 if not supplied and perform the same functionality as the original method, using the substr method.&lt;/span&gt;

 &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startsWith&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchString&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;position&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;position&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;position&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;searchString&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;searchString&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's take another example -&lt;br&gt;&lt;br&gt;
&lt;code&gt;Math.trunc(n)&lt;/code&gt; is a function that “cuts off” the decimal part of a number, e.g &lt;code&gt;Math.trunc(1.11)&lt;/code&gt; returns &lt;code&gt;1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If this function is not supported in some browsers, this function may fail there.&lt;/p&gt;

&lt;p&gt;A polyfill for it may look like this -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trunc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// if no such function implement it&lt;/span&gt;
    &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;trunc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Use the Math.ceil and Math.floor methods supported in legacy browsers to implement it&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ceil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;Number.isNaN&lt;/code&gt; feature earlier had &lt;a href="https://caniuse.com/mdn-javascript_builtins_number_isnan" rel="noopener noreferrer"&gt;limited support&lt;/a&gt; in several browsers. A popular polyfill for it looks like -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// NaN !== NaN returns a true, and hence this logic and exception :) &lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;isNaN&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isNaN&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, remember - &lt;strong&gt;&lt;em&gt;Not all new features are fully polyfillable&lt;/em&gt;&lt;/strong&gt;. Sometimes most of the behaviour can be polyfilled, but there are still small deviations. You should be really, really careful in implementing a polyfill yourself, make sure you are adhering to the specification as strictly as possible. Or better yet, use an already vetted set of polyfills that you can trust, such as those provided by &lt;code&gt;ES5-Shim&lt;/code&gt; and &lt;code&gt;ES6-Shim&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Packages like &lt;a href="https://www.npmjs.com/package/core-js" rel="noopener noreferrer"&gt;Core-js&lt;/a&gt; can help here.&lt;/p&gt;

&lt;h3&gt;
  
  
  Transpilers
&lt;/h3&gt;

&lt;p&gt;A transpiler is software that would translate one piece of code to another.&lt;/p&gt;

&lt;p&gt;It can read modern source code and rewrite it for legacy browser engines, using older syntactic constructs.&lt;/p&gt;

&lt;p&gt;A popular example is the &lt;code&gt;nullish coalescing operator (??)&lt;/code&gt;, JavaScript before 2020 didn't have this operator, so older browser engines would fail to understand something like &lt;code&gt;name = name ?? "No name"&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;A transpiler would understand this and rewrite it to -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// before transpiling&lt;/span&gt;
&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;No name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// after transpiling&lt;/span&gt;
&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;No Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code could be understood by older browsers.&lt;/p&gt;

&lt;p&gt;Developers run the transpiler on their computers and deploy this code to the servers. Some popular transpilers include - &lt;a href="https://babeljs.io/" rel="noopener noreferrer"&gt;Babel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Build systems or bundlers such as &lt;a href="https://webpack.js.org/" rel="noopener noreferrer"&gt;webpack&lt;/a&gt;, provide a means to run a transpiler automatically on every code change. So, they could be integrated into development processes.&lt;/p&gt;

&lt;h3&gt;
  
  
  TL: DR;
&lt;/h3&gt;

&lt;p&gt;In this article, we learned about ways to fill in missing syntactic or functional holes in JavaScript. Polyfills provide a way to fill in functional holes. So you have a way to fill in for that new &lt;strong&gt;&lt;em&gt;shiny, blazing-fast&lt;/em&gt;&lt;/strong&gt; feature in your oldie browsers.&lt;/p&gt;

&lt;p&gt;However, syntactic gaps are hard to fill, since they are just unrecognizable symbols for older engines. Transpilers provide a way to fill in just that.&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Micro Frontends - An exploration</title>
      <dc:creator>Harshita Kanal</dc:creator>
      <pubDate>Mon, 23 Jan 2023 20:46:41 +0000</pubDate>
      <link>https://dev.to/harshitakanal/micro-frontends-an-exploration-3nfc</link>
      <guid>https://dev.to/harshitakanal/micro-frontends-an-exploration-3nfc</guid>
      <description>&lt;p&gt;Micro Frontends extend the concept of Microservices to the frontend world.&lt;/p&gt;

&lt;p&gt;Just like each Microservice can be an independent world of its own where it can run on separate operating systems, query different databases, and have its own processes, Each Microfrontend could be made up of multiple browser-based components, having its own feature to manage, could be built and deployed separately ensuring that they are independent of each other.&lt;/p&gt;

&lt;p&gt;The basic idea behind micro frontends is to think of a web app as a &lt;strong&gt;Composition of features&lt;/strong&gt; and each micro frontend - the frontend for an independent feature often built and managed by different teams.&lt;/p&gt;

&lt;p&gt;In the past, these systems were sometimes referred to as &lt;a href="https://www.otto.de/jobs/technology/techblog/artikel/scaling-with-microservices-and-vertical-decomposition_2014-07-29.php"&gt;Frontend Integration for Verticalised Systems&lt;/a&gt;. But Micro Frontends is clearly - a more friendly name 😅&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages
&lt;/h3&gt;

&lt;p&gt;Some of the advantages of micro frontends include -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;More maintainable, decoupled, smaller codebases.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The ability to update, upgrade and incrementally rewrite parts of the application, which wasn't easily possible earlier.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Trade-offs
&lt;/h3&gt;

&lt;p&gt;However, micro-frontends come with a lot of baggage to handle as well -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Redundant Dependencies&lt;/strong&gt; - A micro-frontend architecture consists of a set of applications that should be able to work with each other as well, each application has its own set of dependencies, and in the long run each application may have multiple different versions of the same dependency, defeating the entire purpose of using package managers. To avoid this, the architecture must incorporate a way of managing common dependencies and minimising redundancies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Overriding styles, inconsistent designs&lt;/strong&gt; - Since the micro-frontends by design cannot have their own set of styles, because the overall web application UI cannot look different in patches, there should be a way of enforcing consistency across the web UI. One way to do that could be - integrating styled components, or enforcing a hard-to-deviate-from design system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Communication and performance issues&lt;/strong&gt; - While developing each part of the application as an independent unit, there should be a way for these parts to interact and communicate with each other, also ensuring that the same set of redundant operations isn't repeated to eventually lead to performance issues is also important.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Implementation of Micro-Frontends
&lt;/h3&gt;

&lt;p&gt;One of the major things to accomplish in Micro-frontend architecture is to establish a way between the host application and the micro-frontends to communicate and integrate.&lt;/p&gt;

&lt;h4&gt;
  
  
  Build-Time Integration
&lt;/h4&gt;

&lt;p&gt;In this case, the host application or container installs the micro-frontends as dependencies or libraries. This however leads to tight dependency between the host application and each of the micro-frontends, whenever a component gets updated, it needs to be updated in the application as well. The size of the production bundle of the application also increases as a result of incorporated dependencies.&lt;/p&gt;

&lt;h4&gt;
  
  
  Run-Time Integration
&lt;/h4&gt;

&lt;p&gt;In the Run-Time integration, the server takes the micro-frontends, composes them and renders them as a single web application. The backend would decide which route to request, and it renders the micro-frontend corresponding to the respective route. Nginx Reverse proxy and AWS CDNs are some ways to implement them.&lt;/p&gt;

&lt;h4&gt;
  
  
  Client Side Composition
&lt;/h4&gt;

&lt;p&gt;In the client-side composition method, the host can be deployed and built separately and the micro-frontends are exposed separately as packages which do not share the same build and deployment processes. Local modules and Remote modules are distinguished. Local modules are regular modules that are part of the current build. Remote modules are modules that are not part of the current build but are loaded at runtime from a remote container.&lt;/p&gt;

&lt;p&gt;Loading remote modules are considered an asynchronous operation.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://webpack.js.org/concepts/module-federation/"&gt;Webpack 5 Module Federation Plugin&lt;/a&gt; is the one of trending ways of implementing this approach.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.thoughtworks.com/radar/techniques/micro-frontends"&gt;&lt;strong&gt;ThoughtWorks Technology Radar: “Micro frontends”&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.manning.com/books/micro-frontends-in-action?a_aid=mfia&amp;amp;a_bid=5f09fdeb"&gt;Book: Micro Frontends in Action&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=dTW7eJsIHDg"&gt;Talk: Micro Frontends - Web Rebels, Oslo 2018&lt;/a&gt; (&lt;a href="https://noti.st/naltatis/HxcUfZ/micro-frontends-think-smaller-avoid-the-monolith-love-the-backend"&gt;Slides&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://medium.com/@tomsoderlund/micro-frontends-a-microservice-approach-to-front-end-web-development-f325ebdadc16"&gt;Post: Micro frontends - a microservice approach to front-end web development&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/micro-frontends-hands-on-example-using-react-webpack-rany"&gt;Micro Frontends Step by Step Using React, Webpack 5, and Module Federation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/deploying-micro-frontends-aws-step-using-gitlab-react-rany"&gt;Deploying Micro Frontends to AWS Step by Step Using React, Webpack 5, and Module Federation&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://rany.elhousieny.com/microfrontends"&gt;https://rany.elhousieny.com/microfrontends&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/understanding-micro-frontends-webpack5-configurations-rany"&gt;Understanding Micro-Frontends Webpack5 configurations Step by Step&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/understanding-micro-frontends-webpack5-module-step-rany"&gt;Understanding Micro-Frontends Webpack5 Module Federation configurations Step by Step&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://martinfowler.com/articles/micro-frontends.html"&gt;Micro Frontends by Martin Fowler&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  TL: DR;
&lt;/h3&gt;

&lt;p&gt;In this article, we discussed one of the trending paradigms in the frontend world - Micro Frontends, their implementation, tradeoffs and advantages. Try diving into these and relating them to the architectural principles used at your org and in your applications to make informed decisions - In the end, enable a paradigm for building scalable frontends capable of adapting to rapidly changing systems.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>architecture</category>
    </item>
    <item>
      <title>CSS In JS - The what, why and How's</title>
      <dc:creator>Harshita Kanal</dc:creator>
      <pubDate>Mon, 23 Jan 2023 20:41:43 +0000</pubDate>
      <link>https://dev.to/harshitakanal/css-in-js-the-what-why-and-hows-1h30</link>
      <guid>https://dev.to/harshitakanal/css-in-js-the-what-why-and-hows-1h30</guid>
      <description>&lt;p&gt;CSS In JS is a practice that allows one to write CSS properties for components in JavaScript. In Runtime CSS In JS, the styles are interpreted and applied at the runtime. It involves using JavaScript libraries to combine styles with component code without needing to use external stylesheets, i.e. writing CSS in &lt;code&gt;.js&lt;/code&gt; files, so that they can work as JS modules. This approach aims to tackle some known issues while working with CSS stylesheets like Scoping, Extensibility, Portability, Specificity, Maintenance etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is it done?
&lt;/h2&gt;

&lt;p&gt;There are different ways to implement CSS In JS, most commonly using either framework-dependent or framework-agnostic libraries. &lt;a href="https://styled-components.com/"&gt;Styled components&lt;/a&gt; are among the most popular of them with over 30,000+ stars on GitHub.&lt;/p&gt;

&lt;p&gt;This is how CSS In JS using styled components in React looks like -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Defining the styles for the element&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="s2"&gt;`
  color: red;
  border: 1px solid blue;
  padding: 10px;
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Using the styled component&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Title&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;World&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Title&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another popular library for writing CSS styles with JavaScript is &lt;a href="https://emotion.sh/docs/introduction"&gt;@emotion/css&lt;/a&gt;. It is framework-agnostic and needs no additional setup, babel plugin, or other config changes for primitive use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;css&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@emotion/css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;white&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CSSInJs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
      &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;css&lt;/span&gt;&lt;span class="s2"&gt;`
        background-color: red;
        font-size: 40px;
        &amp;amp;:hover {
          color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
        }
      `&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="nx"&gt;CSS&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some popular CSS-In-JS libraries are - &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#styled-jsx"&gt;Styled JSX&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#styled-components"&gt;styled-components&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#emotion"&gt;Emotion&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#treat"&gt;Treat&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#typestyle"&gt;TypeStyle&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#fela"&gt;Fela&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#stitches"&gt;Stitches&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#jss"&gt;JSS&lt;/a&gt;, &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#goober"&gt;Goober&lt;/a&gt;, and &lt;a href="https://github.com/andreipfeiffer/css-in-js/blob/main/README.md#compiled"&gt;Compiled&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some Pros of using CSS-In-JS
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Maintenance
&lt;/h3&gt;

&lt;p&gt;Large enterprise projects sometimes require hundreds of stylesheets needed to be maintained on a per-component basis, maintaining them and ensuring that there is minimal repetition to avoid having to deal with large bundle sizes is a task. CSS-In-JS simplifies that by eliminating the need for external stylesheets. A developer however needs to be well-versed in both CSS and JS to be able to seamlessly maintain projects with in-component CSS-In-JS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Minimal Scoping and Specificity problems
&lt;/h3&gt;

&lt;p&gt;Since all the styles are maintained in local scope, there is no need of using stricter selectors or preventing name clashes.&lt;/p&gt;

&lt;p&gt;Styles could be written specifically for one component, without introducing specificity issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic Styling
&lt;/h3&gt;

&lt;p&gt;The ability to apply conditional CSS, ease of theming, and adding styles based on certain conditions, states or prop values can all be achieved using CSS-In-JS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some Cons of CSS-In-JS
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Increase in Bundle Size
&lt;/h3&gt;

&lt;p&gt;It is understandable, the JavaScript for your CSS-In-JS library will also be included in your application bundle. Emotion is &lt;a href="https://bundlephobia.com/package/@emotion/react@11.10.4"&gt;7.9 kB&lt;/a&gt; min-zipped and styled components is 12.7 &lt;a href="https://bundlephobia.com/package/styled-components@5.3.6"&gt;kB&lt;/a&gt;. So neither library is huge, but it all adds up :) (&lt;code&gt;react&lt;/code&gt; + &lt;code&gt;react-dom&lt;/code&gt; is 44.5 kB for comparison.)&lt;/p&gt;

&lt;h3&gt;
  
  
  Server-Side Rendering Support
&lt;/h3&gt;

&lt;p&gt;When it comes to supporting server-side-rendering, there may be many unknown issues that could pop up using CSS-In-JS. Using external component libraries may also not be easy enough. Many CSS-In-JS libraries receive issues related to SSR support. It could be that multiple instances of the library get loaded at once.&lt;/p&gt;

&lt;p&gt;While integrating component libraries, they may not give you full control over the order in which styles are inserted. &lt;a href="https://github.com/emotion-js/emotion/issues/2803"&gt;(Example issue&lt;/a&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Performance Considerations
&lt;/h3&gt;

&lt;p&gt;CSS-In-JS uses JavaScript to process CSS from JavaScript components, this CSS is then injected into DOM. The more the number of components, the more time it would take to make the first paint by the browser.&lt;/p&gt;

&lt;p&gt;CSS caching is used to improve successive page loading time, there is no caching involved in CSS-In-JS. Dynamically generated class names make this more complicated.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL: DR;
&lt;/h2&gt;

&lt;p&gt;In this post, we discussed at length the philosophy of CSS-In-JS, the ways to implement it and the pros and cons of using it.&lt;/p&gt;

&lt;p&gt;There are different advantages and disadvantages associated with both CSS modules and CSS-In-JS, at the end, it depends on your use case, the external component libraries, design systems, and developer skill sets to determine which approach would be more appropriate for your app :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building Chrome Extensions</title>
      <dc:creator>Harshita Kanal</dc:creator>
      <pubDate>Mon, 26 Apr 2021 08:16:42 +0000</pubDate>
      <link>https://dev.to/harshitakanal/building-chrome-extensions-3bpo</link>
      <guid>https://dev.to/harshitakanal/building-chrome-extensions-3bpo</guid>
      <description>&lt;h2&gt;
  
  
  What are chrome extensions?
&lt;/h2&gt;

&lt;p&gt;Chrome extensions can be considered as small programs which add functionality to your chrome browser. &lt;br&gt;&lt;br&gt;
They can help you achieve a variety of tasks, right from manipulating the DOM of your webpage, modifiying the content as per your choice, or providing some tools like screen recorders, all of these can be achieved with the help of chrome extensions. They are visible on the right of the address bar in chrome browser. &lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Pre-requisites of building a chrome extension
&lt;/h2&gt;

&lt;p&gt;You need just the basic knowledge of HTML, CSS and Javascript to get started with your first chrome extension.&lt;/p&gt;
&lt;h2&gt;
  
  
  A hello world extension
&lt;/h2&gt;

&lt;p&gt;The big picture of the process of building a chrome extension could be: &lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Writing the Manifest, HTML, CSS and JS files.&lt;/li&gt;
&lt;li&gt;Packaging them into a .crx zipped file.&lt;/li&gt;
&lt;li&gt;Publishing them to the chrome webstore.
The chrome web store is the place from where the users can install the extension.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Types of Extensions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Browser Action&lt;/strong&gt;: These extensions stay in the toolbar, right next to the address bar and stay there at all the times. They remain accessible everytime. Our hello world extension comes in this category.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Page Action&lt;/strong&gt;: These extensions also stay in the toolbar but remain grayed out or inactive. They become active only on certain pages.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Neither browser action nor Page action&lt;/strong&gt;: These extensions run in the background and achieve certain tasks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The Manifest file
&lt;/h2&gt;

&lt;p&gt;This file is a special file. It contains the information about the chrome extension. It is a .json type file. &lt;br&gt;&lt;br&gt;
It must mandatorily contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Manifest version&lt;/li&gt;
&lt;li&gt;The name of the extension.&lt;/li&gt;
&lt;li&gt;The version of the extension.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Let's get started!
&lt;/h2&gt;

&lt;p&gt;Now that we understand the basics, lets get started buiding the chrome extension. &lt;/p&gt;
&lt;h3&gt;
  
  
  Create a new folder
&lt;/h3&gt;

&lt;p&gt;Make a new folder and create a file named &lt;code&gt;Manifest.json&lt;/code&gt; in it.&lt;br&gt;
The following are the contents of the &lt;code&gt;Manifest.json&lt;/code&gt; file. Put these contents in the file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"manifest_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Hello World Extension"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"This is my first extension!"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"icons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"128"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"icon128.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"48"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"icon48.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"16"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"icon16.png"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"browser_action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"default_icon"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"icon16.png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"default_popup"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"pop.html"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;manifest_version&lt;/code&gt; represents the version of the manifest file. The &lt;code&gt;name&lt;/code&gt; field in the manifest file specifies the name of the extension. The version specifies the version of the extension. This is the first version of our extension, later versions will have higher numbers. The description is the description of the extension.&lt;br&gt;
The icons object specifies the file names of the icons to be used while publishing the extension. They need to be in 3 sizes, &lt;code&gt;128 X 128&lt;/code&gt;, &lt;code&gt;48 X 48&lt;/code&gt;  and &lt;code&gt;16 X 16&lt;/code&gt; to be saved in the same folder, with the corresponding names. &lt;br&gt;&lt;br&gt;
Next we specify that the extension is a browser based extension. The &lt;code&gt;default_icon&lt;/code&gt; represents the icon on the address bar. The default popup represents the popup which would be seen when we click on the icon. It is an html file which we have named as &lt;code&gt;pop.html&lt;/code&gt;. &lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Write the html file
&lt;/h3&gt;

&lt;p&gt;Let's create an html file named &lt;code&gt;pop.html&lt;/code&gt;, out contents of the popup go here. &lt;br&gt;&lt;br&gt;
Put the following contents in it. &lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt; First Extension &lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt; Hello, welcome to my first chrome extension! &lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Trying our extension
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Go to your chrome browser and type &lt;code&gt;chrome://extensions&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Turn the developer mode on by toggling the switch.&lt;/li&gt;
&lt;li&gt;Click on load unpacked button&lt;/li&gt;
&lt;li&gt;Select the folder where you have made the extension.&lt;/li&gt;
&lt;li&gt;That's it! Your extension should now be visible on the page.&lt;/li&gt;
&lt;li&gt;If you click on the puzzle icon in the corner, our &lt;code&gt;h2&lt;/code&gt; should be visible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We just created a basic chrome extension! Congrats! &lt;br&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Exercise
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt; First Extension &amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;h2&amp;gt; Hello, welcome to my first chrome extension! &amp;lt;/h2&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is our static html file, as an exercise, try tweaking with this file and see the changes on the popup.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CSS Selectors: A Primer</title>
      <dc:creator>Harshita Kanal</dc:creator>
      <pubDate>Sun, 15 Nov 2020 19:36:30 +0000</pubDate>
      <link>https://dev.to/harshitakanal/css-selectors-a-primer-1aml</link>
      <guid>https://dev.to/harshitakanal/css-selectors-a-primer-1aml</guid>
      <description>&lt;h2&gt;
  
  
  CSS Selectors
&lt;/h2&gt;

&lt;p&gt;CSS or Cascading Style Sheets is used to style HTML elements.&lt;br&gt;
Element styling typically involves: &lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Selecting the element&lt;/li&gt;
&lt;li&gt;Applying the specific styles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A Typical example of an HTML element could be: &lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt; hello &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the h1 is an HTML element. &lt;br&gt;
Now we need to select this specific element in our CSS file, this would be done by using &lt;br&gt;
a selector.&lt;/p&gt;
&lt;h2&gt;
  
  
  A simple selector
&lt;/h2&gt;

&lt;p&gt;The simplest CSS selector could be, an Element selector.&lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above is an example of an element selector, it would do exactly what its name says, select all specified elements on the page and apply the said styles,in this case it would select all h1 elements and make it red.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get more specific!
&lt;/h2&gt;

&lt;p&gt;Element selectors are good, but we may not need to apply the same styles to all instances of the selected element on the page,&lt;br&gt;
i.e. All h1 elements may not be red! &lt;br&gt;&lt;br&gt;
There could be situations when only some h1 elements need to be red, here we use more specific Selectors.&lt;/p&gt;
&lt;h2&gt;
  
  
  Class selectors
&lt;/h2&gt;

&lt;p&gt;A class selector looks like this: &lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.myColoredTag&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We apply a class to an HTML element as: &lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"myColoredTag"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; hello &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this case, the same set of styles would be applied to all the elements having the same class name.&lt;br&gt;
This could be considered as one of the most used tags, as it can later help you to use various CSS frameworks, example: bootstrap and apply framework specific styles.&lt;/p&gt;
&lt;h2&gt;
  
  
  ID Selectors
&lt;/h2&gt;

&lt;p&gt;An ID selector looks like this: &lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#myColoredTag&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can apply an ID to an HTML element as: &lt;br&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"myColoredTag"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; hello &lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Each page can have only one element with same id, an id is thus unique.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>html</category>
      <category>design</category>
    </item>
  </channel>
</rss>
