<?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>Forem: Technophile</title>
    <description>The latest articles on Forem by Technophile (@technoph1le).</description>
    <link>https://forem.com/technoph1le</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%2F903341%2F1e7bb29e-6af1-4d9f-9982-1491962c53fc.jpg</url>
      <title>Forem: Technophile</title>
      <link>https://forem.com/technoph1le</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/technoph1le"/>
    <language>en</language>
    <item>
      <title>How I make my site searchable in 2 minutes</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Sun, 08 Jun 2025 19:45:14 +0000</pubDate>
      <link>https://forem.com/technoph1le/how-i-make-my-site-searchable-in-2-minutes-48ok</link>
      <guid>https://forem.com/technoph1le/how-i-make-my-site-searchable-in-2-minutes-48ok</guid>
      <description>&lt;p&gt;Your site will not magically show up on Google unless you help search engines to find it.&lt;/p&gt;

&lt;p&gt;So, let’s fix that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic SEO
&lt;/h2&gt;

&lt;p&gt;First things first, in your HTML, add these lines of code in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag:&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;title&amp;gt;&lt;/span&gt;My Awesome Site&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"This summarizes serves as an example. Use this wisely."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"keywords"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"coding, youtube"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"author"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Your Name"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This helps Google understand your content better, plus that's what it shows in Google search page when you look it up.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftuqxx1ei6bo68uj1exsw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftuqxx1ei6bo68uj1exsw.jpeg" alt="Google search result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, if someone shares your site on Discord, Twitter, or LinkedIn — these control how it looks.&lt;/p&gt;

&lt;p&gt;Add these lines as well.&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;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:title"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"My Awesome Site"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:description"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"Check out this cool project I built!"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:image"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"https://yourdomain.com/preview.png"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:url"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"https://yourdomain.com"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;property=&lt;/span&gt;&lt;span class="s"&gt;"og:type"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"website"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While, they're not mandatory, who doesn't like extra SEO boost, right?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjdyr954sgtmx3manmy3.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbjdyr954sgtmx3manmy3.jpeg" alt="Sharing site in Discord"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, add a basic favicon so your site looks legit in tabs:&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;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"icon"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/favicon.ico"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, without one, sites often don't look authentic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdws4c57x74t9e979b7l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgdws4c57x74t9e979b7l.jpeg" alt="Website favicon close-up"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, lastly, add this line to ensure your site doesn't break on phones, because without it Google will dock points for it.&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;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Advanced SEO
&lt;/h2&gt;

&lt;p&gt;That's pretty much it, but if you want go an extra mile, we can generate a sitemap and add it to Google Search console.&lt;/p&gt;

&lt;p&gt;If you're using Vite, install this plugin first in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i vite-plugin-sitemap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in your &lt;code&gt;vite.config.js&lt;/code&gt;, add these lines:&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;Sitemap&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;vite-plugin-sitemap&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Sitemap&lt;/span&gt;&lt;span class="p"&gt;()]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which, should give you a &lt;code&gt;sitemap.xml&lt;/code&gt; at the root. That’s what Google looks for.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4z9ldd0fcywxpbk736l.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb4z9ldd0fcywxpbk736l.jpeg" alt="Sitemap"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, go to Google Search console and link your domain. Here, you need to confirm that you actually own your domain. If you're using Namecheap &amp;amp; Netlify to host your website, all you have to do is copy the TXT value provided by Google search console and add it to the Netlify as a new DNS record.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwk97bz0j3ivslpjeofzu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwk97bz0j3ivslpjeofzu.jpeg" alt="Netlify DNS record"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It takes some time for it to take effect, but then your site should be easily searchable with this max level SEO setup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Video format
&lt;/h2&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/avsuA8O1QrY"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>5 Killer Project Ideas for Developers in 2025</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Sun, 02 Mar 2025 06:11:48 +0000</pubDate>
      <link>https://forem.com/technoph1le/5-killer-project-ideas-for-developers-in-2025-2m6l</link>
      <guid>https://forem.com/technoph1le/5-killer-project-ideas-for-developers-in-2025-2m6l</guid>
      <description>&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/OvZDj9FnnNo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Automated Roadmap Generator&lt;/li&gt;
&lt;li&gt;Leaderboard for Open Source Projects&lt;/li&gt;
&lt;li&gt;Live Coding Interview Platform&lt;/li&gt;
&lt;li&gt;Real-Time Multiplayer Quiz Game&lt;/li&gt;
&lt;li&gt;Personalized Code Snippet Organizer&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Automated Roadmap Generator
&lt;/h2&gt;

&lt;p&gt;No intro. Let's start with an easy one: an automated roadmap generator. Think of it as a tool that helps new developers create personalized learning roadmaps based on their interests. Users can choose non-coder-friendly topics like designing websites or automating tasks, and the platform generates a clear, step-by-step guide tailored to them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisrxiv49oofl0vksl96i.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisrxiv49oofl0vksl96i.jpeg" alt="topics" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can even collaborate with learning platforms to mention or promote their courses, which is a win-win for both parties. For the future plan, one option could be integrate AI to analyze user preferences instead of relying on just multiple-choice questions. It feels more engaging and personalized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fl4q30wk96ol1dcz78r.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fl4q30wk96ol1dcz78r.jpeg" alt="integrate AI in the future" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Here's one pro tip&lt;/strong&gt;: DON'T over-research similar projects. A bit of inspiration from UI designs or core features is fine, but too much digging will leave you feeling like better versions already exist and it can be demotivating. So, get a few inspirations and start building!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Leaderboard for Open Source Projects
&lt;/h2&gt;

&lt;p&gt;Now, it's time for open-source. Contributing is rewarding, but often not in a visible way. Why not change that? Imagine a leaderboard where developers earn points and badges for their contributions. Whether it’s fixing a bug, adding documentation, or implementing a feature, contributors get rewarded, motivating more developers to get involved.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd6hxzp9bp649lc9jbjj9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd6hxzp9bp649lc9jbjj9.jpeg" alt="Types of contributions" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This kind of project especially drives a lot of new developers as well, to engage more with open source. One potential direction could be instead of making it global, you could allow your project to be integrated to other projects, which makes every open unique with their own leaderboards. In terms of handling the scoring, a good starting point could be pulling data from the GitHub API to track contributions. I’m just here to plant the seed, and it’s up to you to make it grow!&lt;/p&gt;




&lt;h2&gt;
  
  
  Live Coding Interview Platform
&lt;/h2&gt;

&lt;p&gt;Now, let’s improve coding interviews! While platforms like LeetCode are great for practicing questions, they lack a key feature: live interviews. Your project could let developers act as either interviewers or interviewees—improving skills on both sides. Points and badges are always a good option to keep users engaged.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy56h0ac47sft4naaf1lm.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy56h0ac47sft4naaf1lm.jpeg" alt="Interviewer and interviewee" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the project itself, you will have to set clear rules and standards to maintain collaborative and safe community for your platform and to avoid turning your project into something chaotic.&lt;/p&gt;




&lt;h2&gt;
  
  
  Real-Time Multiplayer Quiz Game
&lt;/h2&gt;

&lt;p&gt;Next up: a real-time multiplayer quiz game. Platforms like Developer Quiz Site are fun, but solo quizzing can get boring. Why not make it more exciting with real-time competition? Players could race to answer coding-related questions and rack up points. Think of it like Menti but for developers. You can use the similar structure of Developer Quiz Site, where users contribute quiz questions. Plus, it could attract a lot of new contributors as well!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ubiegm9oxgnta621912.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0ubiegm9oxgnta621912.jpeg" alt="Menti platform example" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the future plans, you could even create topic-specific rooms, leaderboards, and achievements to, at the end of the day, make learning fun and addictive.&lt;/p&gt;




&lt;h2&gt;
  
  
  Personalized Code Snippet Organizer
&lt;/h2&gt;

&lt;p&gt;Finally, let’s talk about organizing code. Developers love their code snippets, because it saves a lot of time. But organizing them can be a challenge. You can create a platform to let users organize their snippets by their language, categories or tags, and find them quickly with a search.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdap2qwxwql2msog8kyv.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdap2qwxwql2msog8kyv.jpeg" alt="organizing code" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait... I'm already working on this one! Check out &lt;a href="https://youtu.be/BhRi7fJzPgk?si=75o0_2GyWWRcBc-f" rel="noopener noreferrer"&gt;this video&lt;/a&gt; or visit the &lt;a href="https://github.com/technoph1le/quicksnip" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt; for more. So, this one’s off the table. You’ll have to take one of other four ideas. xD&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftr1ijq4flpzop2zjs5n4.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftr1ijq4flpzop2zjs5n4.jpeg" alt="Project website" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Good luck with your coding journey! As always, thanks for reading, and I’ll see you in the next one.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>coding</category>
    </item>
    <item>
      <title>We made QuickSnip even better (v1)</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Tue, 25 Feb 2025 22:01:31 +0000</pubDate>
      <link>https://forem.com/technoph1le/we-made-quicksnip-even-better-v1-50lo</link>
      <guid>https://forem.com/technoph1le/we-made-quicksnip-even-better-v1-50lo</guid>
      <description>&lt;p&gt;&lt;a href="https://quicksnip.dev" rel="noopener noreferrer"&gt;QuickSnip&lt;/a&gt; is an open-source project that categorizes handy code snippets across various programming languages.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/2_AfhnMVuSY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Excitement
&lt;/h2&gt;

&lt;p&gt;When I published &lt;a href="https://www.youtube.com/watch?v=BhRi7fJzPgk" rel="noopener noreferrer"&gt;the first video&lt;/a&gt;, the project was still draft. Yet, developers loved the idea of storing code snippets and kept suggesting new features and updates.&lt;/p&gt;

&lt;p&gt;My notifications were exploding with likes and views from YouTube as well as issues and PRs from GitHub. And, even VidIQ couldn't keep up with congratulating me on new subscribers count.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ewl286hl4s620myfeyk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ewl286hl4s620myfeyk.png" alt="My GitHub notification filled with issues and PRs" width="800" height="799"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While others were celebrating the New Year, we were reviewing issues and merging pull requests. And honestly, it was one of the best New Year’s I’ve ever had.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fms5rzco156ecolliz5lj.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fms5rzco156ecolliz5lj.jpeg" alt="Me celebrating the new year with my open-source maintainers" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Changes
&lt;/h2&gt;

&lt;p&gt;Okay, let's get back to QuickSnip.&lt;/p&gt;

&lt;p&gt;First things first, we reached our 50 likes target on YouTube in just under 24 hours and as promised, I immediately bought a custom domain for the project. By the way, I collected every single suggestion from both YouTube and GitHub community up until now. And, yes, I wrote them all one by one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5rhflnmksttqef0jbtd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5rhflnmksttqef0jbtd.jpeg" alt="Community requested features and bug reports" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, onto the &lt;strong&gt;changes&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;First big update: we added a light theme and migrated to a new storage system. As our snippet collection grew, managing them in JSON became a difficult task. So, we switched to Markdown for better readability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8jzwltlo9zqm1luskrq.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv8jzwltlo9zqm1luskrq.jpeg" alt="Before" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0m3e6bip7tnpecqg3cd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj0m3e6bip7tnpecqg3cd.jpeg" alt="After" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another major request was adding support for frameworks and libraries. With the new system, adding support became much easier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyqwlus7kzj8ulv13e4n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flyqwlus7kzj8ulv13e4n.png" alt="Support for frameworks" width="501" height="481"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next big change was adding basic search functionality. This feature was quite a long discussion with our maintainers. Yet, finally, we pulled it off. Oh, and you can now share the snippets too!&lt;/p&gt;

&lt;p&gt;Other improvements include cleaner code, bug fixes, hundreds of new snippets, accessibility improvements, cool animations and plenty of quality-of-life updates.&lt;/p&gt;

&lt;p&gt;Also, one of my viewers created a &lt;a href="https://www.raycast.com/anders_morille/quicksnip" rel="noopener noreferrer"&gt;Raycast extension&lt;/a&gt; for QuickSnip. Definitely worth checking it out.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldtj5qlgz81372x335hc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fldtj5qlgz81372x335hc.jpeg" alt="Raycast extension" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I learned more about managing an open-source project in just two weeks than I probably would have in an entire year. I even made a &lt;a href="https://www.youtube.com/watch?v=Lt5Qtj_RvRM" rel="noopener noreferrer"&gt;full 9-minute video&lt;/a&gt; breaking down what I've learned. Check it out and save yourself some time in the future.&lt;/p&gt;




&lt;h2&gt;
  
  
  Future plans
&lt;/h2&gt;

&lt;p&gt;Just like we did with the previous video, let's talk about future plans.&lt;/p&gt;

&lt;p&gt;We created a &lt;a href="https://github.com/technoph1le/quicksnip/blob/main/VISION.md" rel="noopener noreferrer"&gt;&lt;code&gt;VISION.md&lt;/code&gt;&lt;/a&gt; file on GitHub which outlines our potential long-term goals for QuickSnip. For QuickSnip v2.0, the biggest update we're working towards will be the possibility of having private code snippets with personal accounts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbu1ua9tlwmwh0fv9a2w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbbu1ua9tlwmwh0fv9a2w.jpeg" alt="v2.0 plans" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stay tuned for future updates.&lt;/p&gt;

&lt;p&gt;As always, thanks for watching and I'll see you in the next one!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>webdev</category>
      <category>productivity</category>
      <category>news</category>
    </item>
    <item>
      <title>I Built a Game for My 1000 Subscribers</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Fri, 17 Jan 2025 04:25:17 +0000</pubDate>
      <link>https://forem.com/technoph1le/i-built-a-game-for-my-1000-subscribers-4g77</link>
      <guid>https://forem.com/technoph1le/i-built-a-game-for-my-1000-subscribers-4g77</guid>
      <description>&lt;p&gt;We hit 1000 subscribers on 9th of January. To celebrate it with my audience, I wanted to make something special. Then the idea clicked: 1000 subscribers equal 1000 cells. One cell would hide a confetti. And, you, the viewer, would have to find it within a time limit to unlock special perks. And since we're already working with confetti, why not add some confetti animation to make it even more fun?&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/aGzTiHIaLlE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;👉 Play the game here: &lt;a href="https://technophile-1000-subs.netlify.app" rel="noopener noreferrer"&gt;https://technophile-1000-subs.netlify.app&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Design
&lt;/h3&gt;

&lt;p&gt;As always, I started with building the sketch in Figma, because I wanted to play around with different layouts and colors. And, finally, I settled on a complementary cyan and orange palette on a sleek dark theme.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fry23w0sxtync9dh18rgp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fry23w0sxtync9dh18rgp.png" alt="Figma design" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Coding
&lt;/h3&gt;

&lt;p&gt;Now, design is ready, let's get to coding. Why use a framework for a project when you can use Vanilla JavaScript? So, I first built the grid with 1000 cells and hid a confetti in one of them. By the way, when building games like this, I usually prefer Object-Oriented approach, because it makes the code clean and organized.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9amoelhj0mhkk2b4r1rx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9amoelhj0mhkk2b4r1rx.png" alt="Code example" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Layout was done, but, plain cells were not exciting, So, I added a cool hover effect where previously hovered cells slowly fade back to their original color. I used GSAP for this animation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F268fk5sb528pfsw6n725.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F268fk5sb528pfsw6n725.png" alt="GSAP hover effect" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, finding the confetti itself is kinda boring, so, I added a timer for extra challenge. You have 3 minutes to find the confetti. Once you find the hidden confetti, the game reveals how long it took you. Share your best time from your first 3 tries in the comments. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3i01nex3o9qjykpfu81.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3i01nex3o9qjykpfu81.png" alt="Dialog that shows time" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, I added a twist. If you find the confetti fast enough, you unlock special perks. For example, if you manage to beat the game under 1 minute, you will get access to our Discord server, where you can ask any questions from me. &lt;/p&gt;

&lt;p&gt;And, if you find it under 30 seconds, you will get a random secret message which you have to type in this video comment. And, I will make a special mention of hardcore players in my next videos. Secret message might look just like a normal comment. So, no cheating or copying from other comments :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpgapzqtcxf92s5txf8y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flpgapzqtcxf92s5txf8y.png" alt="secret message" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, if you manage to beat it under 10 seconds, well, I won't spoil this one. You'll have to see it for yourself. And, I promise it's NOT a Rickroll xD&lt;/p&gt;

&lt;p&gt;For the finishing touch, I added various confetti animations for each perk. I used the &lt;a href="https://www.kirilv.com/canvas-confetti/" rel="noopener noreferrer"&gt;Canvas Confetti library&lt;/a&gt; for the animations. And, the project is finished.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkin5v9erg26ci8nnpzy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkin5v9erg26ci8nnpzy5.png" alt="Confetti animation" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, try &lt;a href="https://technophile-1000-subs.netlify.app" rel="noopener noreferrer"&gt;this game&lt;/a&gt; out yourself! Let me know your best time. Good luck!&lt;/p&gt;

&lt;p&gt;As always, thanks for reading and I'll see in the next one.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>What I learned managing my first open source</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Mon, 13 Jan 2025 00:16:29 +0000</pubDate>
      <link>https://forem.com/technoph1le/the-journey-of-managing-my-first-open-source-1a7l</link>
      <guid>https://forem.com/technoph1le/the-journey-of-managing-my-first-open-source-1a7l</guid>
      <description>&lt;p&gt;On December 27, 2024, I announced my open-source project, &lt;a href="https://quicksnip.dev/" rel="noopener noreferrer"&gt;QuickSnip&lt;/a&gt;, on &lt;a href="https://youtu.be/BhRi7fJzPgk?si=jSJxAn1pFlfcryrG" rel="noopener noreferrer"&gt;YouTube&lt;/a&gt;. First day was very quiet. And then suddenly, views started to increase. More and more people were watching, commenting and subscribing.&lt;/p&gt;

&lt;p&gt;5 days in, and we're looking at &lt;strong&gt;15k views&lt;/strong&gt; with &lt;strong&gt;1000 likes&lt;/strong&gt; on YouTube and an incredible &lt;strong&gt;200+ stars&lt;/strong&gt; on GitHub.&lt;/p&gt;

&lt;p&gt;So, I decided to share my journey about managing an open-source project with 50+ contributors and over 100 issues and pull requests in these 2 weeks.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Lt5Qtj_RvRM"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;p&gt;That's a lot of things xD&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;README.md and CONTRIBUTING.md&lt;/li&gt;
&lt;li&gt;License&lt;/li&gt;
&lt;li&gt;Prettier&lt;/li&gt;
&lt;li&gt;Collaborators&lt;/li&gt;
&lt;li&gt;CODEOWNERS&lt;/li&gt;
&lt;li&gt;FUNDING&lt;/li&gt;
&lt;li&gt;Discord Server&lt;/li&gt;
&lt;li&gt;Issue Template&lt;/li&gt;
&lt;li&gt;Pull Request Template&lt;/li&gt;
&lt;li&gt;GitHub Actions&lt;/li&gt;
&lt;li&gt;Code of Conduct&lt;/li&gt;
&lt;li&gt;VISION&lt;/li&gt;
&lt;li&gt;Deployment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  README.md and CONTRIBUTING.md
&lt;/h2&gt;

&lt;p&gt;When working on an open-source project, &lt;code&gt;README.md&lt;/code&gt; and &lt;code&gt;CONTRIBUTING.md&lt;/code&gt; files are often overlooked. But, they're the only way contributors can understand what your project is about and how they can contribute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8udvp9e2n02atg64cu2e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8udvp9e2n02atg64cu2e.png" alt="README and CONTRIBUTING files getting ignored" width="660" height="871"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These file explain your expectations for the community. Once you establish solid &lt;code&gt;README.md&lt;/code&gt; and &lt;code&gt;CONTRIBUTING.md&lt;/code&gt; files from the start, it will save you hours when dealing with pull requests. Trust me, this is from experience :)&lt;/p&gt;

&lt;h2&gt;
  
  
  License
&lt;/h2&gt;

&lt;p&gt;Now, let's talk about legal side of open source. You might have already seen a &lt;code&gt;LICENSE&lt;/code&gt; file in pretty much every open-source project, the most common being MIT License. Basically, if a project doesn't have a license, copyright laws kick in automatically. That means others can't use or modify your code, which defeats the whole spirit of encouraging people to use and contribute. That's why always add a license to keep things simple and legal for everyone.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fvtjim02vhyahizqq77.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4fvtjim02vhyahizqq77.png" alt="LICENSE file explained with code" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prettier
&lt;/h2&gt;

&lt;p&gt;Everyone has their own coding style. But, in open-source projects, everyone should be on the same page. And, formatting tools like Prettier set a standard for code style.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwn21pdajpnfmf97au6ux.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwn21pdajpnfmf97au6ux.png" alt="Prettier logo" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As soon as pull requests started rolling in, an immediate issue was code formatting. We immediately created an issue for it and resolved it as quickly as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Collaborators
&lt;/h2&gt;

&lt;p&gt;One major lesson I learned is trust. As the project grew, managing it solo became overwhelming. When people were adding snippets to our database, I noticed a few people consistently reviewing others code and giving great feedback. So, I made them collaborators.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6vwe7ya3emsv7jgj8c2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6vwe7ya3emsv7jgj8c2.png" alt="overwhelming issues and PRs" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, our collaborators help merge pull requests, review issues, and keep things running. I just show them the path and let them lead. If you’re serious about scaling, learn to trust your community.&lt;/p&gt;

&lt;p&gt;And, for personal public repo, like ours, only way to allow your trusted contributors to merge or reject pull requests is through giving them &lt;a href="https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-access-to-your-personal-repositories/inviting-collaborators-to-a-personal-repository" rel="noopener noreferrer"&gt;a collaborator role&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;However, you are not able to assign roles or manage access for collaborators, which I learnt, is possible in organization repo - something we may consider to switch to at some point as we grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  CODEOWNERS
&lt;/h2&gt;

&lt;p&gt;When there's a pull request, it was difficult to know what was it about unless one of our collaborators reviewed it themselves. And, managing hundreds of them can be overwhelming.&lt;/p&gt;

&lt;p&gt;After some research, I found that &lt;a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners" rel="noopener noreferrer"&gt;CODEOWNERS&lt;/a&gt; was a thing. Basically, it will let you assign specific contributors to different parts of your project. For example, we have 3 types of maintainers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Global maintainers, who are responsible for the full scope of the project.&lt;/li&gt;
&lt;li&gt;Code maintainers, who take care of bugs and new features.&lt;/li&gt;
&lt;li&gt;And, last but not least, snippet maintainers, who review snippet-related pull requests, and see whether it fits the scope of QuickSnip.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8qkyh2gtqfjagf0wi2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8qkyh2gtqfjagf0wi2h.png" alt="Our maintainers explained with a graph" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, with CODEOWNERS set up, it will automatically notifies the right maintainers when there's a pull request with a change on their assigned folders.&lt;/p&gt;

&lt;p&gt;But, remember: maintainers need to have &lt;strong&gt;write access&lt;/strong&gt;, so you need to make them collaborators first.&lt;/p&gt;

&lt;h2&gt;
  
  
  FUNDING
&lt;/h2&gt;

&lt;p&gt;I was wondering how some repos had a sponsor button. After digging the settings for a while, I found that you need to create &lt;code&gt;FUNDING.yml&lt;/code&gt; file under &lt;code&gt;.github&lt;/code&gt; folder, in which you can add your any of your sponsor links. I added my &lt;a href="https://ko-fi.com/technoph1le" rel="noopener noreferrer"&gt;Ko-fi link&lt;/a&gt;, and now you can support QuickSnip as well. It's not necessary, but always appreciated. :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7afz0baunaxohrjhykg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7afz0baunaxohrjhykg.png" alt="FUNDING file location on GitHub" width="663" height="153"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Discord server
&lt;/h2&gt;

&lt;p&gt;As more and more people were suggesting new ideas and feature requests, we needed a better way of communication to discuss those ideas with our maintainers. One of our maintainers suggested Discord. Now, we have a QuickSnip Community server, where we discuss ideas and plans.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8s3yugm2rrkrkbuhbe09.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8s3yugm2rrkrkbuhbe09.png" alt="Discord server members" width="455" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's also GitHub Discussions we were experimenting with. But, more people were liking and joining Discord server. So, sorry GitHub Discussions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Issue template
&lt;/h2&gt;

&lt;p&gt;In open-source projects, it's easy to get lost in issues when you have to differentiate what is a bug, feature request or something unrelated.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fep19wtlxvwpg2gic2h28.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fep19wtlxvwpg2gic2h28.png" alt="Is it a bug, feature or unrelated" width="800" height="389"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, I visited other open-source projects to get an idea on how they are managing their issues. And, I came across Developer Quiz Site from FreeCodeCamp. When I tried to create an issue and I saw this: 4 options to choose from:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Bug report&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;Feature request&lt;/li&gt;
&lt;li&gt;And, general&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7g3a3orxiioa3kps3ky.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7g3a3orxiioa3kps3ky.png" alt="type of issues" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was very clean and organized. After taking some inspirations, I implemented them in our own project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pull Request template
&lt;/h2&gt;

&lt;p&gt;Now, PRs were next.&lt;/p&gt;

&lt;p&gt;In our project, some pull requests didn't follow style guide or sometimes had no descriptions. It made it difficult for our maintainers to review the PRs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwln0u8vzd6si3u03ev36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwln0u8vzd6si3u03ev36.png" alt="Very angry maintainers" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, to my luck, there were pull request templates as well. Thank you, GitHub. First, I gathered feedback from our maintainers what they would like to add in pull request template so it can save their time. Then, I created one. It contains the type of change, an important checklist, related issues and additional info.&lt;/p&gt;

&lt;p&gt;Now, every PR is clear and consistent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1x86ffxry8zll3rbfi5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1x86ffxry8zll3rbfi5b.png" alt="PR template" width="800" height="718"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  GitHub Actions
&lt;/h2&gt;

&lt;p&gt;GitHub Actions feels like magic, but in reality, it's a really cool feature. QuickSnip now stores snippets as markdown files, but the frontend uses JSON to show them in the website. Manually converting markdown to JSON? No thanks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xwmx1wfd2maafi8d9em.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2xwmx1wfd2maafi8d9em.png" alt="The magic of GitHub Actions" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We wrote a script in GitHub Actions and automated it. Now, whenever someone adds a new snippet, it converts the files automatically. I’ll talk more about this in my next video. Stay tuned!&lt;/p&gt;

&lt;h2&gt;
  
  
  Code of Conduct
&lt;/h2&gt;

&lt;p&gt;Code of Conduct is often misunderstood on what it actually means. I’ll admit — I thought Code of Conduct was about style guides at first. Turns out, it’s a set of rules people should follow to create a welcoming environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3havy4iiu7w1ib5s61n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm3havy4iiu7w1ib5s61n.png" alt="Code of Conduct is community rules" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our community has been fantastic so far, and as we grow, a Code of Conduct will ensure we're always friendly and kind to each other.&lt;/p&gt;

&lt;h2&gt;
  
  
  VISION
&lt;/h2&gt;

&lt;p&gt;As the project started to gain traction (which is awesome), a lot of ideas and feature requests began pouring in (which is even more awesome). But, the problem was it was easy to lose focus. We realized it was important to set the boundaries and understand the scope and future of QuickSnip.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4n2hgncqj9qqd57nw8pg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4n2hgncqj9qqd57nw8pg.png" alt="It's easy to lose focus" width="800" height="452"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Inspired from &lt;a href="https://contributing.md/best-practices-for-maintainers-of-open-source-projects/" rel="noopener noreferrer"&gt;this article&lt;/a&gt; on &lt;code&gt;contributing.md&lt;/code&gt; website, we created a file, called &lt;code&gt;VISION.md&lt;/code&gt;, which outlines the goals, roadmap and the future of QuickSnip. While it outlines the current vision for QuickSnip, our proposed future plans may evolve based on community feedback and contributions. So, stay tuned for future updates! ;) &lt;/p&gt;

&lt;p&gt;The main purpose of &lt;code&gt;VISION.md&lt;/code&gt; file is stay focused on your goals. As the article puts it perfectly: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;"As a new maintainer, one person narrates how he regrets steering away from his vision in the early stages of his project when he got his first feature request. He appreciates that a clear vision has kept him focused and helped him prioritize important requests."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;

&lt;p&gt;QuickSnip is hosted on Netlify, and here’s a surprise I didn’t see coming: build minutes.&lt;/p&gt;

&lt;p&gt;Since the project is on Free plan, there's limit on build minutes, which is 300. Basically, it's about how many minutes it takes from loading your dependencies (all the code stuff) to deploying them to the site.&lt;/p&gt;

&lt;p&gt;And, according to &lt;a href="https://www.netlify.com/pricing/faq/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;, each build takes around 2 minutes.&lt;/p&gt;

&lt;p&gt;I didn't know about build minutes until I got an email notification from Netlify saying I had reached over 50% of build minutes. That is when I started to take action. I assume, what was happening was that  Netlify was also counting build minutes for every PR request since it had to show deploy previews before PR is merged. So, I had to disable deploy previews.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0vl6ftq5zdbbw3yly9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0vl6ftq5zdbbw3yly9u.png" alt="50% build minutes reached in a few days" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Luckily, thanks to Netlify, build minutes are reset every month. I was so excited to find out about this. In our project, build minutes will reset on January 17, just one day after my birthday.&lt;/p&gt;

&lt;h2&gt;
  
  
  Outro
&lt;/h2&gt;

&lt;p&gt;These past two weeks taught me more than an entire year. So, here's a small tip from my side: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Open-source is challenging, rewarding, and full of surprises. If you haven’t started an open-source project yet—do it now. You’ll grow, learn, and connect with amazing people.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As always, thanks for reading and I will see you in the next one.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>tutorial</category>
      <category>learning</category>
      <category>github</category>
    </item>
    <item>
      <title>I built a library of code snippets for developers</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Fri, 27 Dec 2024 14:04:36 +0000</pubDate>
      <link>https://forem.com/technoph1le/i-built-a-library-of-code-snippets-d66</link>
      <guid>https://forem.com/technoph1le/i-built-a-library-of-code-snippets-d66</guid>
      <description>&lt;p&gt;This article is more like a coding journey/journal, where I explain the "behind the scenes" and explain my thought process. If you prefer visual version, I've also made a video of it:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/BhRi7fJzPgk"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  Idea
&lt;/h2&gt;

&lt;p&gt;I've been writing code for over three years now, and one thing that takes up most of my time is repetitive code. As programmers, we don't like repetitive work, especially, writing the same code over and over again. So, I thought why not store all these repetitive pieces of code in one place? Somewhere I could just copy and paste from whenever I needed.&lt;/p&gt;

&lt;p&gt;This idea was brewing in my head for a while. I also remembered sharing &lt;a href="https://dev.to/technoph1le/10-helpful-javascript-utility-functions-35oc"&gt;JavaScript utility functions&lt;/a&gt; on DEV Community a while ago. And, people loved them and were making suggestions to improve them as well.&lt;/p&gt;

&lt;p&gt;And, I thought what if these code snippets were stored in one organized, easy-to-access place, and what if it was driven by the community itself?&lt;/p&gt;

&lt;p&gt;And, the idea for QuickSnip was born...&lt;/p&gt;




&lt;h2&gt;
  
  
  Design
&lt;/h2&gt;

&lt;p&gt;Before jumping into the project, I wanted to make sure I had a clear vision. So, I sat down with ChatGPT to brainstorm ideas for the project name, logo, and architecture. After gathering all the details, I hopped onto Figma to sketch out the wireframe.&lt;/p&gt;

&lt;p&gt;By the way, I took some inspirations from &lt;a href="https://stacksorted.com/buttons" rel="noopener noreferrer"&gt;Stack Sorted.&lt;/a&gt;  So, shout-out to them.&lt;/p&gt;

&lt;p&gt;After a few days, design was ready, and it was time to move on to the fun part: coding.&lt;/p&gt;




&lt;h2&gt;
  
  
  Coding
&lt;/h2&gt;

&lt;p&gt;I decided to go with React, TypeScript, and Vite. Frontend took around a week to get everything in place.&lt;/p&gt;

&lt;p&gt;Then came the backend. I wanted to use a routing system inspired by &lt;strong&gt;Stack Sorted.&lt;/strong&gt;. Since it was a single-page application, I ran into several issues with routing. But after a lot of trial and error, I managed to get it working.&lt;/p&gt;

&lt;p&gt;However, after a week-long break and revisiting the code, I knew that the code was impossible to understand, not to mention maintaining it in the future. So, just like a normal programmer, instead of refactoring, I decided to scrap it all and start over. &lt;/p&gt;

&lt;p&gt;This time, I simplified the architecture and used Context API for state management. It’s not the cleanest code ever, but hey, if it works, it works!&lt;/p&gt;

&lt;p&gt;For syntax highlighting, I chose &lt;a href="https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/prism.html" rel="noopener noreferrer"&gt;React Syntax Highlighter&lt;/a&gt; powered by &lt;strong&gt;Prism.JS&lt;/strong&gt; because it was super simple and easy to integrate.&lt;/p&gt;

&lt;p&gt;Now, for storing the code snippets, I took inspiration from other &lt;a href="https://github.com/freeCodeCamp/Developer_Quiz_Site/blob/main/src/data/accessibility-quiz.ts" rel="noopener noreferrer"&gt;open-source projects&lt;/a&gt; and decided to use a local database, so others can add their own snippets easily. The snippets are stored in JSON files under the &lt;code&gt;/public/data&lt;/code&gt; folder. Each programming language has its own file, and within each file, snippets are grouped into categories.&lt;/p&gt;

&lt;p&gt;Here’s an example of how it’s structured:&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;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Name of the snippet"&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;"A short explanation of what the snippet does"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"code"&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="s2"&gt;"your code goes here"&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 a newline with a space"&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;"tags"&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="s2"&gt;"tag1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tag2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"tag3"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"your_github_username"&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;For &lt;code&gt;code&lt;/code&gt;  part, initially, I used single-line string to store the snippet code. It was compact but at a cost of readability.&lt;/p&gt;

&lt;p&gt;After some back-and-forth with ChatGPT, I realized I could use arrays instead. That made the code so much easier to inspect and understand.&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="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;before&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;"code"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"def reverse_string(s):&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;   return s[::-1]"&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="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;after&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;"code"&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="s2"&gt;"def reverse_string(s):"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"    return s[::-1]"&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;After many more UI adjustments and hours spent cleaning up the code, QuickSnip was finally coming together.&lt;/p&gt;




&lt;h2&gt;
  
  
  Documentation
&lt;/h2&gt;

&lt;p&gt;But, there was something missing. For every open source project, there should be a clear documentation to help contributors understand what your project is about and how they can contribute.&lt;/p&gt;

&lt;p&gt;I wasn’t very experienced with managing open-source project, but by some chance, if you type &lt;code&gt;contributing.md&lt;/code&gt; into your browser, it will take you directly to an &lt;a href="https://contributing.md/" rel="noopener noreferrer"&gt;awesome guide&lt;/a&gt; to help you get started with open-source projects.&lt;/p&gt;

&lt;p&gt;After some research, I managed to create beginner-friendly guides in both &lt;code&gt;README.md&lt;/code&gt; and &lt;code&gt;CONTRIBUTING.md&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;QuickSnip is now live on Netlify! You can check it out at &lt;code&gt;quicksnip.netlify.app&lt;/code&gt;. Why not &lt;code&gt;.com&lt;/code&gt;? Because, well, I’m broke right now. But hey, if &lt;a href="https://youtu.be/BhRi7fJzPgk?si=gxfxv1ooCvJfCD3a" rel="noopener noreferrer"&gt;this video&lt;/a&gt; gets 50 likes, I’ll buy a custom domain!&lt;/p&gt;

&lt;p&gt;I also launched QuickSnip on &lt;a href="https://www.producthunt.com/products/quicksnip" rel="noopener noreferrer"&gt;&lt;strong&gt;Product Hunt&lt;/strong&gt;&lt;/a&gt;. It’s my first time launching a project there. So, now, you can leave a review there as well.&lt;/p&gt;




&lt;h2&gt;
  
  
  How to contribute
&lt;/h2&gt;

&lt;p&gt;Speaking of contribution, you can either help by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding new snippets or&lt;/li&gt;
&lt;li&gt;Improving the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have written easy-to-understand explanation in &lt;a href="https://github.com/dostonnabotov/quicksnip/blob/main/CONTRIBUTING.md" rel="noopener noreferrer"&gt;&lt;code&gt;CONTRIBUTING.md&lt;/code&gt;&lt;/a&gt; on how to contribute to this project, along with adding snippets, categories and languages.&lt;/p&gt;

&lt;p&gt;Remember: whether you're fixing a tiny typo, found a bug or have a feature request, every bit means a lot. Thank you! :)&lt;/p&gt;




&lt;h2&gt;
  
  
  Future plans
&lt;/h2&gt;

&lt;p&gt;After weeks of coding and debugging, I can now proudly check off this mark.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fou63h4sboflfsjsz9ixs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fou63h4sboflfsjsz9ixs.png" alt="Final checklist for QuickSnip" width="800" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait... there are still more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ohk9b40ldldk540q51b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3ohk9b40ldldk540q51b.png" alt="Future checklist for QuickSnip" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ok. Let's talk about future plans.&lt;/p&gt;

&lt;p&gt;For now, the search functionality isn’t working yet. I’ve been looking into &lt;a href="https://www.algolia.com/" rel="noopener noreferrer"&gt;Algolia&lt;/a&gt; as a solution and I am planning to implement it soon. So, stay tuned!&lt;/p&gt;

&lt;p&gt;I will keep adding more features based on your feedback and suggestions to hopefully make our coding journey easier and more enjoyable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;To wrap it up. here's a question: Do you have a favorite code snippet that you use all the time? One that you think every developer could benefit from? If so, now’s your chance to &lt;a href="https://quicksnip.netlify.app/" rel="noopener noreferrer"&gt;share it&lt;/a&gt; with the world.&lt;/p&gt;

&lt;p&gt;As always, thanks for reading and I'll see you in the next one.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>opensource</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>I built a Sass template. You can just copy me!</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Thu, 19 Dec 2024 18:59:20 +0000</pubDate>
      <link>https://forem.com/technoph1le/i-built-a-sass-template-you-can-just-copy-me-213o</link>
      <guid>https://forem.com/technoph1le/i-built-a-sass-template-you-can-just-copy-me-213o</guid>
      <description>&lt;p&gt;The last &lt;a href="https://dev.to/technoph1le/a-modern-sass-folder-structure-330f"&gt;Sass template&lt;/a&gt; I made was over 2 years ago. I decided to share it with the internet and it ended up getting 35k views.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zrywfik2rd5ytik8u13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8zrywfik2rd5ytik8u13.png" alt="35k views screenshot" width="800" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lot has changed since then. So, I decided to rework it and share it with more people.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/GevImMd3o6c"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This is currently my latest Sass folder structure that I use for pretty much every project, except for minor variations in files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbxwbfq9e6cs0k52yqp78.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbxwbfq9e6cs0k52yqp78.png" alt="Sass Folder structure" width="576" height="436"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  How to download and use it
&lt;/h2&gt;

&lt;p&gt;To use this template in your project, you can either click on &lt;code&gt;Use this template&lt;/code&gt; on &lt;a href="https://github.com/dostonnabotov/sass-template" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Or you can just download the &lt;code&gt;sass&lt;/code&gt; folder and include it in your current project and start using it.&lt;/p&gt;




&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;

&lt;p&gt;Ok, let's get back to the folders. There are 6 folders and 1 main &lt;code&gt;style.scss&lt;/code&gt; file.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;abstracts&lt;/code&gt; folder
&lt;/h3&gt;

&lt;p&gt;Starting with the 1st folder: &lt;code&gt;abstracts&lt;/code&gt;. This folder is only used for Sass-related things. And, nothing from this folder gets compiled into CSS.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdyrha3epd3abhjwk6l66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdyrha3epd3abhjwk6l66.png" alt="files structure" width="525" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a place where you write all your variables, mixins, functions, placeholders, maps and etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;base&lt;/code&gt; folder
&lt;/h3&gt;

&lt;p&gt;Next up, &lt;code&gt;base&lt;/code&gt; folder. This folder contains base or generic styles for your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukatc74o36lxulssuy1s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fukatc74o36lxulssuy1s.png" alt="files structure" width="528" height="277"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where I put my reset styles, custom properties and global styles that are not specific to any element.&lt;/p&gt;

&lt;p&gt;Also, I don't change any files in both &lt;code&gt;abstracts&lt;/code&gt; and &lt;code&gt;base&lt;/code&gt; folder since the architecture is usually the same in most of my projects.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;components&lt;/code&gt; folder
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;components&lt;/code&gt; folder. As the name suggests, this folder holds all the styles for specific components used in the project. This can include buttons, cards, drop down, input fields and so on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjo1lkwihdqc2ritr3vk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjo1lkwihdqc2ritr3vk.png" alt="files structure" width="511" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This folder usually gets big if you have many reusable components in your website.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;layouts&lt;/code&gt; folder
&lt;/h3&gt;

&lt;p&gt;And, unlike &lt;code&gt;components&lt;/code&gt; folder, &lt;code&gt;layouts&lt;/code&gt; folder contains 1 level higher styles that are used define the structure of your website. This can be things like &lt;code&gt;header&lt;/code&gt;, &lt;code&gt;footer&lt;/code&gt; or &lt;code&gt;sidebar&lt;/code&gt; of your website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsfrgrbjfx0uuod1nnix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsfrgrbjfx0uuod1nnix.png" alt="files structure" width="533" height="273"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;pages&lt;/code&gt; folder
&lt;/h3&gt;

&lt;p&gt;Moving on, &lt;code&gt;pages&lt;/code&gt; folder contains page-specific styles that don’t apply globally. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fae8qp5taaxyycjjonw37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fae8qp5taaxyycjjonw37.png" alt="files structure" width="524" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, we can't put &lt;code&gt;header&lt;/code&gt; in &lt;code&gt;pages&lt;/code&gt; folder, since it's used in every page, but we CAN put the "Teams" section styles in our &lt;code&gt;_about.scss&lt;/code&gt; file. Also, we can put the article related styles in our &lt;code&gt;_blog.scss&lt;/code&gt; file. Because they're only used or at least make sense in those pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;utilities&lt;/code&gt; folder
&lt;/h3&gt;

&lt;p&gt;Similar to &lt;code&gt;components&lt;/code&gt; folder, &lt;code&gt;utilities&lt;/code&gt; folder holds specific styles for our project. But, what's the difference?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifrtlc4kjy79p5pgi51b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifrtlc4kjy79p5pgi51b.png" alt="files structure" width="529" height="282"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's take a text example. Let's say, there's a class name, called &lt;code&gt;.text-highlight&lt;/code&gt;. When used in a project, its only purpose is to highlight the text, and not interfere with other text styles. But, you may say, so does the &lt;code&gt;components&lt;/code&gt; folder. In &lt;code&gt;components&lt;/code&gt; folder, styles are often encapsulated or a separate unit, like a button, cards or input fields. But, in &lt;code&gt;utilities&lt;/code&gt; folder, it's not a separate unit, it's changing the existing element. As we saw with &lt;code&gt;.text-highlight&lt;/code&gt;, it's not a separate thing on its own, like &lt;code&gt;button&lt;/code&gt;, but rather changing the existing text to a different style.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxk9hqtgt4omx0nhuska1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxk9hqtgt4omx0nhuska1.png" alt="text-highlight class" width="800" height="350"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another good example would be &lt;code&gt;.container&lt;/code&gt; class. I can use the &lt;code&gt;.container&lt;/code&gt; class anywhere in HTML, and it wraps that element and sets a width to it. In other words, It does one thing and does it well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk7rd60y80myn1buu2u1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk7rd60y80myn1buu2u1.png" alt="container class" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, we have a file, called &lt;code&gt;_shame.scss&lt;/code&gt;. This is a concept I learned from "Sass Guidelines". Basically, if you feel like, the style you wrote doesn't belong any file or folder, you should put them in &lt;code&gt;_shame.scss&lt;/code&gt;. We put this file at the very end of our stylesheet, which we can use it for debugging purposes as well.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcu69h4eg8544hqmxsgrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcu69h4eg8544hqmxsgrb.png" alt="shame file example" width="800" height="604"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, this is an only file where you can freely use &lt;code&gt;!important&lt;/code&gt; or an &lt;code&gt;id&lt;/code&gt; selector, and go wild with them. But, make sure to sort and filter them out once you have found a good solution to your problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;_index.scss&lt;/code&gt; file
&lt;/h3&gt;

&lt;p&gt;You have might already noticed that each folder has a file, called &lt;code&gt;_index.scss&lt;/code&gt;. This is because of &lt;code&gt;@use&lt;/code&gt; and &lt;code&gt;@forward&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In old Sass, we used to import files with &lt;code&gt;@import&lt;/code&gt;, but, now we have a modern solution: &lt;code&gt;@use&lt;/code&gt; which is &lt;a href="https://sass-lang.com/documentation/at-rules/use/#differences-from-import" rel="noopener noreferrer"&gt;created to replace&lt;/a&gt; the old &lt;code&gt;@import&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also, it comes with some other cool features, which you can read &lt;a href="https://sass-lang.com/documentation/at-rules/use/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If we look at the &lt;code&gt;_index.scss&lt;/code&gt; files, we can see that there are only &lt;code&gt;@forwards&lt;/code&gt; which we will use to export the files within the folder. By doing this, I can import the whole folder at once, instead of importing each file individually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm795dc7z5bqxr1omgzlw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm795dc7z5bqxr1omgzlw.png" alt="forwarding files in index file" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, in our main &lt;code&gt;style.scss&lt;/code&gt;, we import the files with &lt;code&gt;@use&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1y7zdpbzij2k0n700lt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1y7zdpbzij2k0n700lt.png" alt="main style file" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want use a variable or mixin from your &lt;code&gt;abstracts&lt;/code&gt; folder into your &lt;code&gt;_button.scss&lt;/code&gt; file, you can import it by writing&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@use&lt;/span&gt; &lt;span class="s2"&gt;"../abstracts"&lt;/span&gt; &lt;span class="nt"&gt;as&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Often times, you will only need to import your &lt;code&gt;abstracts&lt;/code&gt; folder. That means, this line never changes, so whenever you need to use anything from your &lt;code&gt;abstracts&lt;/code&gt; folder, just copy and paste this line and you're good to go.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9n0juml6gsm08bpou1c0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9n0juml6gsm08bpou1c0.png" alt="example of importing abstracts folder" width="800" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fun fact: I've also used &lt;code&gt;@use&lt;/code&gt; and &lt;code&gt;@forward&lt;/code&gt; in my first sass template 2 years ago.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;style.scss&lt;/code&gt; file
&lt;/h3&gt;

&lt;p&gt;Last, but not least, our main &lt;code&gt;style.scss&lt;/code&gt; file, where everything gets merged into one place. And, the order they are merged is also important since it defines which style should override the other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1y7zdpbzij2k0n700lt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc1y7zdpbzij2k0n700lt.png" alt="main style file" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I made this diagram to show how files should be ordered. Feel free to inspect it on &lt;a href="https://github.com/dostonnabotov/sass-template" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff1pje3nkmoguqskr97xx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff1pje3nkmoguqskr97xx.png" alt="SCSS files order" width="800" height="526"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Outro
&lt;/h2&gt;

&lt;p&gt;And, that's it. This folder structure was and is heavily inspired by &lt;a href="https://sass-guidelin.es/#the-7-1-pattern" rel="noopener noreferrer"&gt;the 7-1 pattern&lt;/a&gt; in Sass Guidelines as well as Kevin Powell's &lt;a href="https://youtu.be/9Ld-aOKsEDk?si=72TeqJjkXz3iUwZ6" rel="noopener noreferrer"&gt;video on Sass&lt;/a&gt;. So, shoutout to them.&lt;/p&gt;

&lt;p&gt;This was the start of "I built something" series where I share my interesting &amp;amp; cool projects, and explain my thought process behind it.&lt;/p&gt;

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

&lt;p&gt;As always, thanks for reading. And, I will see you in the next one. :)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>5 Good CSS Habits - Explained with a Real Project</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Tue, 03 Dec 2024 13:56:12 +0000</pubDate>
      <link>https://forem.com/technoph1le/the-only-css-guide-you-will-need-1mb7</link>
      <guid>https://forem.com/technoph1le/the-only-css-guide-you-will-need-1mb7</guid>
      <description>&lt;p&gt;We will cover topics ranging from naming selectors, organizing your code to specificity and which units to pick. I divided this guide into 5 habits that are important for every developer learning or improving their CSS.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/vmJ9j6BdX_g"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Habit #1: Consistent naming&lt;/li&gt;
&lt;li&gt;Habit #2: Use CSS variables&lt;/li&gt;
&lt;li&gt;Habit #3: Comment and organize&lt;/li&gt;
&lt;li&gt;Habit #4: Always use classes&lt;/li&gt;
&lt;li&gt;Habit #5: Use appropriate unit&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Habit #1: Consistent naming
&lt;/h2&gt;

&lt;p&gt;Can you look at the following selectors in CSS, and answer these 3 questions: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WHAT do they do?&lt;/li&gt;
&lt;li&gt;WHERE can they be used?&lt;/li&gt;
&lt;li&gt;and are they RELATED to each other?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xxm1kubk0aumzqu8zal.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xxm1kubk0aumzqu8zal.png" alt="Unrelated selectors" width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We know that &lt;code&gt;.title&lt;/code&gt; class is used to style the title, but, it doesn't tell us whether it's the main &lt;em&gt;title&lt;/em&gt; of the website or the &lt;em&gt;title&lt;/em&gt; of some article. And, we don't know if it's related to &lt;code&gt;.card&lt;/code&gt; element at all.&lt;/p&gt;

&lt;p&gt;And, it's same issue with the other classes, too. Without looking at the HTML code, we can't answer those 3 questions.&lt;/p&gt;

&lt;p&gt;Just like other programming languages, CSS has adopted its own naming rules that developers should follow.&lt;/p&gt;

&lt;p&gt;These include the following: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Names should be written in lowercase&lt;/li&gt;
&lt;li&gt;Separate the words with hyphens (-)&lt;/li&gt;
&lt;li&gt;Don't use camelCase, under_score or other naming conventions.&lt;/li&gt;
&lt;li&gt;And, here's my personal take: don't use abbreviations unless they're commonly used among developers. like &lt;code&gt;bg&lt;/code&gt; for &lt;code&gt;background&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, still, these are not enough to answer those 3 questions, especially when your project starts to grow.&lt;/p&gt;

&lt;p&gt;Then, what is that secret sauce?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rfycxb8ku97v2kkphoz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6rfycxb8ku97v2kkphoz.png" alt="famous chef adding salt" width="452" height="454"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's &lt;strong&gt;BEM&lt;/strong&gt;, the most popular naming convention in CSS among developers.&lt;/p&gt;

&lt;p&gt;Let's look at our previous example and see how we apply this approach.&lt;/p&gt;

&lt;p&gt;Looking at the HTML first, we can see that they're pricing cards. Each card has a class name, called &lt;code&gt;.card&lt;/code&gt;. Inside, there’s a title, price and a list of features. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzt21b4qjyv0s7mza4ham.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzt21b4qjyv0s7mza4ham.png" alt="HTMl code" width="800" height="577"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's use the BEM approach and change the &lt;code&gt;.title&lt;/code&gt; to &lt;code&gt;.card__title&lt;/code&gt;. Now, we know that it belongs to the &lt;code&gt;.card&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Let's apply the same logic for the other ones, too. Change them from &lt;code&gt;.price&lt;/code&gt; to &lt;code&gt;.card__price&lt;/code&gt;, and from &lt;code&gt;.features&lt;/code&gt; to &lt;code&gt;.card__features&lt;/code&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;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.bg-primary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.big-text&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__price&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__features&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn932zmiq4mbcjhxofpox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn932zmiq4mbcjhxofpox.png" alt="Final output so far" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, what if one of the cards is a popular option and has a different background color. In that case, we add a new class name next to the &lt;code&gt;.card&lt;/code&gt;, called &lt;code&gt;.card--popular&lt;/code&gt;. And, then we can add the different background color to that new class name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jm2dwkiyotwcybagm9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6jm2dwkiyotwcybagm9f.png" alt="Added background color in the popular option" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, the font size of the price in the popular card is bigger than other ones, so let’s add a new class name to it, called &lt;code&gt;.card__price--big&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljfbpktd4jtntgpcculh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljfbpktd4jtntgpcculh.png" alt="Increased font size" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;HTML code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9k5um9j72dmz5ouhlztz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9k5um9j72dmz5ouhlztz.png" alt="HTML Code" width="800" height="541"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, BEM makes the code so much easier to read. And, most importantly, it answers the 3 fundamental questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WHAT does it do?&lt;/li&gt;
&lt;li&gt;WHERE could it be used?&lt;/li&gt;
&lt;li&gt;and is it RELATED to other elements?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next time when you are naming selectors, try to cover all these questions.&lt;/p&gt;

&lt;p&gt;Also, if you want to dive deeper into BEM, you read this &lt;a href="https://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/" rel="noopener noreferrer"&gt;awesome article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Okay, let's continue.&lt;/p&gt;




&lt;h2&gt;
  
  
  Habit #2: Use CSS variables
&lt;/h2&gt;

&lt;p&gt;Here’s a question for you. Do you know what color is this?&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;.class__name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#191970&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;Well, it’s dark blue. Now, here’s the next question: Is it a primary color, an accent color, or just a random one-off color used in the project?&lt;/p&gt;

&lt;p&gt;That’s the problem. Without additional context, like looking at the design file or visiting the website, it’s difficult to know.&lt;/p&gt;

&lt;p&gt;Solution? &lt;/p&gt;

&lt;p&gt;CSS custom properties (AKA variables)&lt;/p&gt;

&lt;p&gt;You might probably have heard the term, DRY (Don't Repeat Yourself) principle. If you find yourself repeating the same values or copy-pasting them across your CSS, you should store them as variables. &lt;/p&gt;

&lt;p&gt;Let’s take our color example, and refactor it using variables. A good starting point is naming the variable by the color itself. In our case, it could be:&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="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--darkblue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#191970&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.class__name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--darkblue&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;Now that we used this variable, there's a potential problem here. What happens if the color itself changes to &lt;code&gt;red&lt;/code&gt; or &lt;code&gt;green&lt;/code&gt;? Suddenly, the name &lt;code&gt;--darkblue&lt;/code&gt; doesn’t make sense anymore. &lt;/p&gt;

&lt;p&gt;To solve this, avoid naming variables based on their literal value. Instead, name them according to their &lt;strong&gt;purpose&lt;/strong&gt;. For example, if this color is the primary color of our project, we can name the variable &lt;code&gt;--primary-color&lt;/code&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="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--primary-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#191970&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card--popular&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--primary-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--primary-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, even if the color changes to green or any other color, variable name still makes sense.&lt;/p&gt;

&lt;p&gt;Bonus tip: You can also use variables to store some random or complicated value. It will give a better context on what it is.&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="c"&gt;/* bad */&lt;/span&gt;
&lt;span class="nc"&gt;.element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="m"&gt;0.3s&lt;/span&gt; &lt;span class="n"&gt;cubic-bezier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* good */&lt;/span&gt;
&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--ease-out&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;cubic-bezier&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="m"&gt;0.3s&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--ease-out&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;h2&gt;
  
  
  Habit #3: Comment and organize
&lt;/h2&gt;

&lt;p&gt;Writing comments... Either you like it or hate it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzc6emrggg22wsiqdxeti.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzc6emrggg22wsiqdxeti.jpg" alt="Cat showing like thumb" width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, comments in CSS are not just for giving explanations, they can also be used to organize and structure your code.&lt;/p&gt;

&lt;p&gt;But, before that let’s first start with the intended use case: adding explanations.&lt;/p&gt;

&lt;p&gt;Take a look the following code. Without the comments, can you tell me what it does?&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;.auto-grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto-fit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;22rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&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;How about now?&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="c"&gt;/* this is for auto-grid, lol */&lt;/span&gt;
&lt;span class="nc"&gt;.auto-grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto-fit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;22rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&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;Just kidding, but seriously, how about now?&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="c"&gt;/** 
 * Responsive gird that adjusts columns automatically
 * Each item has a minimum width of 22rem and a maximum of 100%
 **/&lt;/span&gt;
&lt;span class="nc"&gt;.auto-grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;auto-fit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;minmax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;22rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&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;I know that we all hate writing comments in our code. But, if it's the only thing you can understand, try to give at least some explanations. Trust me, otherwise, you will forget it eventually.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5bab4cjvdexe3x7vib9j.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5bab4cjvdexe3x7vib9j.jpg" alt="" width="800" height="785"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can ask ChatGPT to give a short and clean comment on how your code works.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbr2t8616lx307r6xet6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbr2t8616lx307r6xet6.png" alt="ChatGPT responded with " width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s move to the second use case: organizing and grouping your code with comments.&lt;/p&gt;

&lt;p&gt;If you're working with a single CSS file, you might already know that it gets messy real quick. And, it becomes a nightmare especially when you're trying to find that one selector. So, grouping similar or related blocks makes your file and life much easier.&lt;/p&gt;

&lt;p&gt;Let's take our previous example, and apply this approach.&lt;/p&gt;

&lt;p&gt;In our case, we can separate the global styles and group them in one place, ideally at the top of our file. (I will explain later why) Next, we can separate some of the components that we used in our project and group them together. Now, finally, our main cards. Since, we organized them by their name, we can now easily group them into one place and make it easy to separate from the rest of the code.&lt;/p&gt;

&lt;p&gt;If you're not sure about how to actually structure your CSS, you can use the 7-1 approach (&lt;a href="https://sass-guidelin.es/#the-7-1-pattern" rel="noopener noreferrer"&gt;https://sass-guidelin.es/#the-7-1-pattern&lt;/a&gt;) to understand where each piece of your code belongs to. Although it's designed for Sass folders, you can apply the architecture itself into your single CSS file.&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="c"&gt;/*------------------------------------*\
  #GLOBAL
\*------------------------------------*/&lt;/span&gt;
&lt;span class="o"&gt;*,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;::after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;h3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*------------------------------------*\
  #COMPONENTS
\*------------------------------------*/&lt;/span&gt;
&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/*------------------------------------*\
  #CARDS
\*------------------------------------*/&lt;/span&gt;
&lt;span class="nc"&gt;.cards&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card--popular&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__price&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__price--big&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__features&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__features&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&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, when you're separating the blocks, make it easy for your eyes to spot them. I use this commenting approach by Harry Roberts in his &lt;a href="https://cssguidelin.es/#meaningful-whitespace" rel="noopener noreferrer"&gt;CSS Guidelines&lt;/a&gt;. And, they look clean, too.&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="c"&gt;/*------------------------------------*\
  #FOO
\*------------------------------------*/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Habit #4: Always use classes
&lt;/h2&gt;

&lt;p&gt;Don’t use HTML elements as selectors, like &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;p&lt;/code&gt;, and &lt;code&gt;button&lt;/code&gt;. You're only allowed to use them when you are applying global styles. But, if it’s something specific, always use classes. Even if it feels like extra step, you will thank yourself in the future.&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="c"&gt;/* bad */&lt;/span&gt;
&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;....&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;....&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="c"&gt;/* good */&lt;/span&gt;
&lt;span class="nc"&gt;.button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;....&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.button&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;....&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And, speaking of HTML elements, don’t use ID selectors. You might have already heard the term “specificity”. If you haven’t, basically, every selector has its own specificity or “importance” score. You can view it in VS Code by hovering over the selector. The higher the score, the more “important” it is, which means it becomes much difficult to override its style with other lower scored selectors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq72bvek4skecp2fc6piw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq72bvek4skecp2fc6piw.png" alt="Specificity score in VS Code" width="800" height="534"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might think it’s a good thing. But, it’s not often the case. If you look at habit #3, we put the general styles at the top of the file. And, components, utilities and other specific styles are placed at the bottom. It’s because general styles are later overridden by specific styles.&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="c"&gt;/* lose */&lt;/span&gt;
&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-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;span class="c"&gt;/* win */&lt;/span&gt;
&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&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;In CSS, whichever style is applied last will be used. And, in our case, if we use an ID selector somewhere in CSS, and later down the page, try to override its style with a class name, it doesn’t work, because the “specificity” of an id selector is higher than of a class selector.&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="c"&gt;/* win */&lt;/span&gt;
&lt;span class="nf"&gt;#card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-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;span class="c"&gt;/* many lines later... */&lt;/span&gt;

&lt;span class="c"&gt;/* lose */&lt;/span&gt;
&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&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, &lt;code&gt;!important&lt;/code&gt; falls in the same category. Don’t use it unless absolutely necessary, such as for debugging why your style is not being applied to your element.&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;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt; &lt;span class="cp"&gt;!important&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* only for testing */&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On a similar note, don’t nest or chain selectors. It also increases the specificity score and makes it harder to maintain. Instead give it a separate class name. If you are unsure about what to name it, refer to habit #1.&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="c"&gt;/* bad */&lt;/span&gt;
&lt;span class="nc"&gt;.card__features&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="c"&gt;/* good */&lt;/span&gt;
&lt;span class="nc"&gt;.card__feature&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;....&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Habit #5: Use appropriate unit
&lt;/h2&gt;

&lt;p&gt;If you’re only using pixels (&lt;code&gt;px&lt;/code&gt;) in your CSS, either you’re a beginner or living under the rock. Because you are missing out on so many cool features that other units can offer. And, it’s important to understand where to use them effectively.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu91gee2la8130ipn4aca.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu91gee2la8130ipn4aca.jpg" alt="Living under the rock" width="800" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s my general approach on using units in CSS for different cases:&lt;/p&gt;

&lt;h3&gt;
  
  
  For font sizes
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;rem&lt;/code&gt;. Because it's proven to work better than other units, including &lt;code&gt;px&lt;/code&gt;. You can read it &lt;a href="https://dev.to/ochukodotspace/the-battle-of-the-units-px-vs-rem-vs-em-3ka8"&gt;here&lt;/a&gt;, &lt;a href="https://austingil.com/px-or-rem-in-css/" rel="noopener noreferrer"&gt;here&lt;/a&gt; and &lt;a href="https://vanmarciano.pro/beginners-guide-to-rem-em-and-px/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For width and height
&lt;/h3&gt;

&lt;p&gt;It's quite tricky. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If it is really specific number, use &lt;code&gt;rem&lt;/code&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But, if it is not the case, you can use &lt;code&gt;%&lt;/code&gt;, because they work really well most of the time. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;vw&lt;/code&gt; and &lt;code&gt;vh&lt;/code&gt; can be also good depending on the use case. But, I often face overflow issue with them. So, be careful. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;But, if you're controlling the width of a paragraph or text, &lt;code&gt;ch&lt;/code&gt; is often a good option. It stands for characters, which means you can specify how many characters you want per line. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For paddings, margins  and gaps
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If you want consistent output that doesn't change and fail, use &lt;code&gt;rem&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you want them to change based on font size, &lt;code&gt;em&lt;/code&gt; works really well. &lt;code&gt;em&lt;/code&gt; unit depends on the font size of the nearby content. You can leverage it to create responsive spacing with fluid font sizes as well.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  For other cases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you are dealing with very small sizes, like &lt;code&gt;4px&lt;/code&gt; or &lt;code&gt;8px&lt;/code&gt; where the difference is not that noticeable, you can use &lt;code&gt;px&lt;/code&gt;. Because &lt;code&gt;0.125rem&lt;/code&gt; or &lt;code&gt;0.375rem&lt;/code&gt; might be difficult to understand at first sight compared to &lt;code&gt;2px&lt;/code&gt; or &lt;code&gt;6px&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these units can be overwhelming especially if you want consistent approach in your CSS. But, learning to adopt to different solutions can be a game changer when you understand where to use them.&lt;/p&gt;




&lt;h2&gt;
  
  
  Outro
&lt;/h2&gt;

&lt;p&gt;And, that's pretty much it. Hope you find this article helpful. If you ever struggle with how to write CSS, you can always come back to this article.&lt;/p&gt;

&lt;p&gt;And, of course, there are so many ways of writing CSS, and only limit is your imagination. &lt;/p&gt;

&lt;p&gt;Thanks to all developers and their awesome articles. I just gathered them all from years of learning into one hopefully useful article for you.&lt;/p&gt;

&lt;p&gt;And, as always, thanks for reading and I’ll see you in the next one.&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>I Found The CLEANEST Loading Animation EVER!</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Wed, 20 Nov 2024 20:55:02 +0000</pubDate>
      <link>https://forem.com/technoph1le/i-found-the-cleanest-loading-animation-ever-4ln1</link>
      <guid>https://forem.com/technoph1le/i-found-the-cleanest-loading-animation-ever-4ln1</guid>
      <description>&lt;p&gt;I recently noticed that Netlify has the most minimalist loading animation I have ever seen. So, I decided to build it myself and share it with you.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/cfpREf8UEs8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Looking at the loading animation in Netlify website, we can see that it uses 4 characters (&lt;code&gt;|&lt;/code&gt;, &lt;code&gt;/&lt;/code&gt;, &lt;code&gt;-&lt;/code&gt;, and &lt;code&gt;\&lt;/code&gt;) to create the illusion of spinning effect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrucfih08qgdvqpv1ibc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrucfih08qgdvqpv1ibc.gif" alt="Original loading animation in Netlify" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That means, we can store the characters in array and repeatedly   cycle through each one of them. We also need to find the perfect sweet point for our animation timing and speed create that cool spinning effect.&lt;/p&gt;

&lt;p&gt;Ok, let's get started.&lt;/p&gt;




&lt;p&gt;First, let's setup the loader in HTML. It's just a &lt;code&gt;div&lt;/code&gt; with an &lt;code&gt;id&lt;/code&gt; of "loader":&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;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"loader"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Now, with CSS, let's center it in the screen and increase the size:&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;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;place-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&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;Done. Now onto JavaScript.&lt;/p&gt;

&lt;p&gt;First, let's get the loader element from HTML and store it in a variable. We also need to create an array to store the 4 characters for our animation. I'm using letters here to see the animation difference better.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loader&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;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d&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;Now, whenever you need to animate something in JavaScript, you can use this thing called &lt;code&gt;requestAnimationFrame()&lt;/code&gt;. Basically, it tells the browser that we want to perform an animation. I will explain how.&lt;/p&gt;

&lt;p&gt;Let's create a function, called &lt;code&gt;animate()&lt;/code&gt;. Inside, we run the  &lt;code&gt;requestAnimationFrame()&lt;/code&gt; and pass &lt;code&gt;animate&lt;/code&gt; itself as an argument. And, finally, let's call the &lt;code&gt;animate()&lt;/code&gt; function itself at the end. Because &lt;code&gt;requestAnimationFrame()&lt;/code&gt; runs only once, with this technique we create an infinite loop.&lt;/p&gt;






&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animate&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="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Right now, nothing seems to be happening. But, &lt;code&gt;animate()&lt;/code&gt; function is continuously running in the background. &lt;/p&gt;

&lt;p&gt;Now, to see it, let's create a variable, called &lt;code&gt;frame&lt;/code&gt;, set it to 0, and increment it every time &lt;code&gt;animate()&lt;/code&gt; function runs.&lt;/p&gt;

&lt;p&gt;If we &lt;code&gt;console.log&lt;/code&gt; it, we can see the number incrementing. It's quite fast!&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;frame&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animate&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="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;frame&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7a35xyawsciv8hx7jlty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7a35xyawsciv8hx7jlty.png" alt="frame variable incrementing in the console" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's update our &lt;code&gt;loader&lt;/code&gt; to show each character as &lt;code&gt;animate()&lt;/code&gt; function runs.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loader&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;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;frame&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animate&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="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&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;Here, I'm using &lt;code&gt;%&lt;/code&gt; sign (also known as modulo operator) to cycle through the array elements. I'm using 3, since the last index of the array is 3. That way, we always stay within the array.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5vm8016qyezs94cii1h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5vm8016qyezs94cii1h.png" alt="Array Index" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Looking at the output, it's working but a little too fast. &lt;/p&gt;

&lt;p&gt;Do you remember, when we &lt;code&gt;console.log&lt;/code&gt;ed the &lt;code&gt;frame&lt;/code&gt; variable, it was incrementing so fast? Basically, what is happening is that we're changing the &lt;code&gt;loader&lt;/code&gt; character every frame. If, let's say, we manage to update it every 10 frame or 20 frame, it would slow down the animation speed.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loader&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;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;frame&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animate&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&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="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, there'e an issue with our code. Because we're updating every 10 frames (10, 20, 30 and etc), &lt;code&gt;characters[frame % 3]&lt;/code&gt; no longer cycles the array correctly.&lt;/p&gt;

&lt;p&gt;So, I found a easier and better approach to solve this.&lt;/p&gt;

&lt;p&gt;Let's create a separate variable, called &lt;code&gt;index&lt;/code&gt; that track which character we're showing. And, if the &lt;code&gt;index&lt;/code&gt; gets bigger than our array length, we reset it to 0.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loader&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;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;frame&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animate&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&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="nx"&gt;index&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="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we can freely chose when to update the content, and not worry about characters not showing up correctly.&lt;/p&gt;

&lt;p&gt;Try different frame intervals to control the speed - higher values slow down the animation and lower values speed it up.&lt;/p&gt;

&lt;p&gt;Now, if we change the letters back to characters, we get the same result as we saw with Netlify 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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;loader&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;loader&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;characters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;|&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;frame&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="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;index&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;animate&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;frame&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;10&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&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="nx"&gt;index&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="nx"&gt;loader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;characters&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;frame&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;requestAnimationFrame&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4n0jlzg18x0gp7u39iy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4n0jlzg18x0gp7u39iy.gif" alt="Final result" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And, that's it. Hope you learned something new. &lt;/p&gt;

&lt;p&gt;As always, thanks for reading and I'll see you in the next one.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>learning</category>
    </item>
    <item>
      <title>3 Tricks to Make Your Fonts Responsive</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Fri, 08 Nov 2024 00:30:03 +0000</pubDate>
      <link>https://forem.com/technoph1le/3-methods-of-solving-un-responsive-fonts-w-css-414o</link>
      <guid>https://forem.com/technoph1le/3-methods-of-solving-un-responsive-fonts-w-css-414o</guid>
      <description>&lt;p&gt;Responsive fonts…&lt;/p&gt;

&lt;p&gt;As text plays a big role in websites, you want to make sure that it looks great for everyone no matter what device they use. And, it gets tricky as there are so many screen sizes to worry about.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/xcUWAism9iM?start=7"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Let’s first take a look at some examples of &lt;em&gt;UN-responsive&lt;/em&gt; fonts to understand why it matters. Some developers use desktop-first approach when building websites, while others use mobile-first. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r96sehqfhv9qtyl3h1w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r96sehqfhv9qtyl3h1w.gif" alt="Desktop vs mobile first approach" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, sometimes, when working with desktop-first approach, the text size is often ignored, because they look normal on computers. But, when you open it on your phone, it looks like this...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ckh1fhkztxantfrklk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ckh1fhkztxantfrklk1.png" alt="Unresponsive text" width="439" height="876"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I will show you &lt;strong&gt;3&lt;/strong&gt; methods of solving this issue. I divided them into 3 levels:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Easy&lt;/li&gt;
&lt;li&gt;Medium&lt;/li&gt;
&lt;li&gt;Hardcore&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  1. Easy - change fonts based on viewport
&lt;/h2&gt;

&lt;p&gt;Let’s start with easy one.&lt;/p&gt;

&lt;p&gt;It’s not actually easy and can get tricky if you’re new to media queries. Basically, we first declare our variables in CSS, because we can use them later in our code. Next, let’s name our variables and set values.&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="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--font-sm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.875rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--font-md&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--font-lg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.25rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--font-xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.75rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--font-2xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--font-3xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4rem&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;And, yes, &lt;code&gt;rem&lt;/code&gt; is better than &lt;code&gt;px&lt;/code&gt;. You can read it &lt;a href="https://dev.to/ochukodotspace/the-battle-of-the-units-px-vs-rem-vs-em-3ka8"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Okay, we finished with our base font sizes. Let’s see how it looks. Let me set it up real quick…&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;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--font-md&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--font-3xl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--font-2xl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h3&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--font-xl&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h4&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--font-lg&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;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fliha38kk3mma2vygeeqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fliha38kk3mma2vygeeqr.png" alt="Output in browser" width="800" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s not responsive yet. I want the text size to change when it reaches a certain viewport. Let’s say &lt;code&gt;600px&lt;/code&gt;. Past the value, text looks too big on phones. Thus, we use media query to change the values of our variables we set up earlier.&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="k"&gt;@media&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="err"&gt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;--font-sm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.875rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--font-md&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--font-lg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.25rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--font-xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--font-2xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;--font-3xl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3rem&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;For this time, we want the values to be smaller than original because we are working on mobile device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8eranosdmgmmwf3almpu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8eranosdmgmmwf3almpu.gif" alt="Result in browser" width="600" height="338"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, it rather snaps to the different value, doesn’t flow smoothly, because we set it up that way. &lt;/p&gt;

&lt;p&gt;You can use it as a foundation for your projects, so they don’t end up looking huge overflowing text.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Medium - use type scale calculators
&lt;/h2&gt;

&lt;p&gt;Easy, but difficult to comprehend one. You can use type calculators, like &lt;a href="https://utopia.fyi/type/calculator/" rel="noopener noreferrer"&gt;Utopia.fyi&lt;/a&gt; to generate the best responsive font sizes for you.&lt;/p&gt;

&lt;p&gt;We first set the minimum and maximum font size for our base font, like paragraph. And, we have to set the type scale ratio. The calculator generates the font sizes based on these values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0jam8ul73e1hk0f1mrm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp0jam8ul73e1hk0f1mrm.png" alt="Utopia type calculator" width="800" height="389"&gt;&lt;/a&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="c"&gt;/* @link https://utopia.fyi/type/calculator?c=320,16,1.2,1240,18,1.25,5,2,&amp;amp;s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&amp;amp;g=s,l,xl,12 */&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--step--2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.6944rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.6856rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.0444vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.72rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step--1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0.8333rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.8101rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.1159vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.9rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step-0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.9565rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.2174vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.125rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step-1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.2rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.1283rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.3587vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.4063rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step-2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.44rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.3295rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.5527vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.7578rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step-3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.728rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.5648rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.8161vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2.1973rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step-4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2.0736rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1.8395rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1.1704vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2.7466rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--step-5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;clamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2.4883rem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2.1597rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1.6433vw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3.4332rem&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;As you can see, it uses clamp() to generate responsive font sizes. Just copy the values, and paste them into your CSS. Change the names of variables. And, you are good to go.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Hardcore - write your own type scale calculator
&lt;/h2&gt;

&lt;p&gt;If you really want to have full control of your responsive fonts, you can build your own type scale calculator. Although I usually use Utopia.fyi for most of my projects, here’s how I would implement it without these tools.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="k"&gt;@use&lt;/span&gt; &lt;span class="s2"&gt;"sass:math"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$font-scale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="mi"&gt;.25&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$font-min&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="mi"&gt;.875rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$font-base&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$font-max&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="mi"&gt;.125rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$font-sizes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s2"&gt;"xs"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"sm"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"md"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"lg"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"xl"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"2xl"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"3xl"&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;@each&lt;/span&gt; &lt;span class="nv"&gt;$label&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="nv"&gt;$font-sizes&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$min-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$font-min&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$font-scale&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$base-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$font-base&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$font-scale&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$max-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;$font-max&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$font-scale&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nt"&gt;--font-&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nv"&gt;$label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="nd"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;clamp&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
      &lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nv"&gt;$min-size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
      &lt;span class="nt"&gt;calc&lt;/span&gt;&lt;span class="o"&gt;((&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nv"&gt;$base-size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nt"&gt;0&lt;/span&gt;&lt;span class="nc"&gt;.5&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nt"&gt;2vw&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
      &lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nv"&gt;$max-size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;)&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;I used Sass here to automate the process. Here's the &lt;a href="https://codepen.io/technoph1le/pen/jOgvyKo" rel="noopener noreferrer"&gt;link to Codepen&lt;/a&gt; if you want to view it. It’s not the cleanest code in the world. If you have your own approach, please let me know in the comment.&lt;/p&gt;




&lt;p&gt;And, there you have it! Hope you learned something new. Let me know which approach you’re going with. As always, thanks for reading, and I’ll see you in the next one! 👋&lt;/p&gt;

</description>
      <category>css</category>
      <category>a11y</category>
      <category>typography</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Fetch Local Files Easily with THIS Technique</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Wed, 30 Oct 2024 03:02:20 +0000</pubDate>
      <link>https://forem.com/technoph1le/how-to-fetch-a-json-file-with-javascript-promises-vs-asyncawait-26bo</link>
      <guid>https://forem.com/technoph1le/how-to-fetch-a-json-file-with-javascript-promises-vs-asyncawait-26bo</guid>
      <description>&lt;p&gt;Hey everyone! Welcome back. In today’s post, I’m going to show you how to fetch a JSON file with JavaScript in two ways: using &lt;code&gt;promises&lt;/code&gt; and using &lt;code&gt;async/await&lt;/code&gt;. We'll compare both methods and discuss which one might be better for your code. &lt;/p&gt;

&lt;p&gt;You can also watch the YouTube video I made:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/tEb0DM-cIdo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;First, let’s look at the JSON file we want to fetch. It contains simple data about users:&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="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;"John"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"New York"&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;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;"Dan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;26&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"London"&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;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;"Mark"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"city"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Berlin"&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;Now, let’s see how we can fetch this data and use it in our javascript file using both approaches. Btw, make sure that files are located in the same folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Fetching JSON with Promises
&lt;/h2&gt;

&lt;p&gt;Ok, let’s start with promises. We can use the built-in JavaScript fetch() method to retrieve our data:&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="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./data.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&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;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;data&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;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;data&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;error&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;fetch()&lt;/code&gt; method retrieves the data from provided location, in our case, it is &lt;code&gt;data.json&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;The first &lt;code&gt;.then()&lt;/code&gt; method converts the response back to JSON format with &lt;code&gt;res.json()&lt;/code&gt; function.&lt;/li&gt;
&lt;li&gt;In the next &lt;code&gt;.then()&lt;/code&gt; method we handle the JSON data and log it to the console.&lt;/li&gt;
&lt;li&gt;Finally, &lt;code&gt;.catch()&lt;/code&gt; method handles any errors that occur with fetching the data, such as wrong file location.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Fetching JSON with Async/Await
&lt;/h2&gt;

&lt;p&gt;Now let’s see how to do the same thing using &lt;code&gt;async/await&lt;/code&gt;.&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;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;try&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;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./data.json&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&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;span class="nf"&gt;fetchData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this version:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We define an &lt;code&gt;async&lt;/code&gt; function called &lt;code&gt;fetchData()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;We are using try and catch block to handle any errors, just like &lt;code&gt;catch()&lt;/code&gt; method in our previous example.&lt;/li&gt;
&lt;li&gt;Inside, we use the &lt;code&gt;await&lt;/code&gt; keyword to wait for the fetch request to complete and then converts the response to JSON format, and finally, we receive the data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Which One is Better?
&lt;/h2&gt;

&lt;p&gt;Ok, we now know how to fetch the data. So, what’s the difference between these two approaches?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Promises&lt;/strong&gt; offers a simple way to work with callbacks, but the syntax can become messy and harder to follow when dealing with multiple asynchronous operations. &lt;/li&gt;
&lt;li&gt;While &lt;strong&gt;Async/Await&lt;/strong&gt; reads more like synchronous code, making it easier to debug and maintain, especially in more complex applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In general, &lt;code&gt;async/await&lt;/code&gt; is the cleaner and more readable approach, and it’s recommended when you’re working with multiple asynchronous actions or want to avoid the callback hell.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Solving Cross-Origin Issues
&lt;/h2&gt;

&lt;p&gt;One quick thing to note: If you try to open the HTML file directly into your browser or run nodejs to see the output of your data, you might encounter a Cross-Origin Request Blocked error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08vqcsje7i5kg06sc7aq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F08vqcsje7i5kg06sc7aq.png" alt="Cross-Origin Request Blocked error" width="800" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The reason is that they don’t have access to reading your internal files. To fix this, you can either:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer" rel="noopener noreferrer"&gt;Live Server extension&lt;/a&gt; in VS Code, so that it runs your project on a local server. (and, it’s much easier when testing locally)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5z0tgzebkkwhan4slec.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5z0tgzebkkwhan4slec.png" alt="Live Server extension" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfdbgivpewq6b6q3azvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfdbgivpewq6b6q3azvd.png" alt="Data fetched in local server" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Or deploy your project to a platform like &lt;a href="https://pages.github.com/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt; or &lt;a href="https://www.netlify.com/" rel="noopener noreferrer"&gt;Netlify&lt;/a&gt;, which we’ll quickly cover now.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 5: Deploying the Project to GitHub Pages
&lt;/h2&gt;

&lt;p&gt;Once your project is working locally, you can now deploy it using GitHub Pages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Push your project to GitHub.&lt;/li&gt;
&lt;li&gt;In your repository, go to &lt;code&gt;Settings&lt;/code&gt; &amp;gt; &lt;code&gt;Pages&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Select the branch and folder to publish your site.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once your site is live, you should be good to go.&lt;/p&gt;

&lt;p&gt;And there you have it! You now know how to fetch JSON using both promises and async/await.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>json</category>
      <category>api</category>
    </item>
    <item>
      <title>5 Websites You NEED As a Frontend Developer</title>
      <dc:creator>Technophile</dc:creator>
      <pubDate>Wed, 23 Oct 2024 05:40:20 +0000</pubDate>
      <link>https://forem.com/technoph1le/5-websites-for-frontend-devs-4ne0</link>
      <guid>https://forem.com/technoph1le/5-websites-for-frontend-devs-4ne0</guid>
      <description>&lt;p&gt;Hello everyone! Today, I’ve got 5 websites that every frontend developer, and even other programmers, should know about. These are the sites I personally use everyday, and I think you’ll love them too. So, let’s dive in!&lt;/p&gt;

&lt;p&gt;By the way, if you're a visual reader, you can also watch the YouTube video I made.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hQhFAJnKtPo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  1. MDN Web Docs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft23c5d7lru6svn1giyfi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft23c5d7lru6svn1giyfi.png" alt="MDN Web Docs website preview" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Link: &lt;a href="https://developer.mozilla.org/en-US/" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s start with MDN Web Docs. I think for frontend developers, MDN Web Docs is one of the best resources out there in terms of documentation.&lt;/p&gt;

&lt;p&gt;MDN covers basically pretty much everything in web technologies, including HTML, CSS, and JavaScript. &lt;/p&gt;

&lt;p&gt;💡 Fun Fact: Even VS Code uses MDN as a reference for code suggestions. &lt;/p&gt;

&lt;p&gt;Oh, btw, Do you know what does MDN stand for? It’s the Mozilla Developer Network. Yep, the same company that created the Firefox browser. 🦊&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Carbon
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhiv0szc9smp770wjn83y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhiv0szc9smp770wjn83y.png" alt="Carbon website preview" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Link: &lt;a href="https://carbon.now.sh/" rel="noopener noreferrer"&gt;https://carbon.now.sh/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we’ve covered the documentation, let’s talk about writing beautiful code. Ever wanted to share a piece of code you’re proud of on a social media or your blog, but it looks ugly? Don’t worry! Because Carbon is here to fix it. 🎨&lt;/p&gt;

&lt;p&gt;Carbon lets generate beautiful images of your code. In this website, you can tweak pretty much everything - the theme, background, font, spacing and etc.&lt;/p&gt;

&lt;p&gt;It’s a great tool to make your code look shiny on social media.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. CanIUse.com
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ddmcsj2dt07jkyrqi6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9ddmcsj2dt07jkyrqi6u.png" alt="caniuse.com website" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Link: &lt;a href="https://caniuse.com/" rel="noopener noreferrer"&gt;https://caniuse.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ever come across a new CSS feature, only to find out that it works on your computer, but not your phone or vice verse. This is where caniuse.com can be very useful. Basically, it helps you check what browsers support this new feature. 🔍&lt;/p&gt;

&lt;p&gt;I remember waiting for ages for the full support for Flexbox’s gap property and now it’s supported in almost 95% of browsers.&lt;/p&gt;

&lt;p&gt;Next time, you see a new feature, always make sure to check it in this website before using it in your projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Realtime Colors
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylw1ympg9idpygers8nb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylw1ympg9idpygers8nb.png" alt="Realtime Colors website preview" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Link: &lt;a href="https://www.realtimecolors.com/" rel="noopener noreferrer"&gt;https://www.realtimecolors.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let’s talk about design. Before starting a new project, it’s important to choose colors carefully. Otherwise, it can ruin the user experience. With Realtime Colors, you can visualize color palettes in real-time and see how they’d look on a website. 🎨&lt;/p&gt;

&lt;p&gt;You can either choose a color palette you have in mind or just keep pressing the Spacebar until you find the one you like. Once done, you can copy the colors or download it into your computer. Definitely a great tool!&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Favicon.io
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2ifo9qjv550e85oily7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw2ifo9qjv550e85oily7.png" alt="Favicon website preview" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 Link: &lt;a href="https://favicon.io/" rel="noopener noreferrer"&gt;https://favicon.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last but not least, let’s not forget about little details—like your site’s favicon! You know, that tiny logo that appears in the browser tab. With Favicon.io, you can generate those tiny logos from simple text, an image, or even an emoji. It’s quick, easy, and a great way to personalize your website. 👨🏻‍💻&lt;/p&gt;




&lt;p&gt;And there you have it. If you have other websites you use on a daily basis, feel free to write them in the comments. Who knows, I might make a video/post about them in the future! 💬&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
