<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jiawei Li</title>
    <description>The latest articles on DEV Community by Jiawei Li (@zhcalvin).</description>
    <link>https://dev.to/zhcalvin</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%2F828304%2Ff9b8beb3-b0c9-45d1-9779-ef78b70ab77a.jpeg</url>
      <title>DEV Community: Jiawei Li</title>
      <link>https://dev.to/zhcalvin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zhcalvin"/>
    <language>en</language>
    <item>
      <title>Ways to Reduce your Front-End Codes</title>
      <dc:creator>Jiawei Li</dc:creator>
      <pubDate>Sat, 02 Apr 2022 11:44:18 +0000</pubDate>
      <link>https://dev.to/zhcalvin/ways-to-reduce-your-front-end-codes-30hl</link>
      <guid>https://dev.to/zhcalvin/ways-to-reduce-your-front-end-codes-30hl</guid>
      <description>&lt;p&gt;Here, several approaches will be introduced to reduce your front-end code base, especially, for reducing css codes. &lt;/p&gt;

&lt;h2&gt;
  
  
  Tailwind
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Link: &lt;a href="https://tailwindcss.com/docs/installation" rel="noopener noreferrer"&gt;tailwindcss&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;tailwindcss&lt;/code&gt; provides fast, flexible, reliable css classes. Using &lt;code&gt;tailwind&lt;/code&gt; you can save time writing your css codes.&lt;/p&gt;

&lt;p&gt;For instance, &lt;code&gt;truncate&lt;/code&gt; for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h4&gt;
  
  
  To optimize css codes in production
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Refer to &lt;a href="https://cssnano.co/" rel="noopener noreferrer"&gt;cssnano&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Brotli" rel="noopener noreferrer"&gt;Brotli&lt;/a&gt; as mentioned in &lt;a href="https://tailwindcss.com/docs/optimizing-for-production" rel="noopener noreferrer"&gt;tailwind docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  css-checker
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Link: &lt;a href="https://github.com/ruilisi/css-checker" rel="noopener noreferrer"&gt;css-checker&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wonder how to find your duplicated css codes? There is a automatic tool that can help you scanning all your css &amp;amp; styled-components codes and show similar classes with diffs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.ruilisi.com%2Fcss-checker-demo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.ruilisi.com%2Fcss-checker-demo.gif" alt="DEMO"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To Install:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g css-checker-kit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;To Run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;css-checker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using useSWR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Link: &lt;a href="https://swr.vercel.app/en-US" rel="noopener noreferrer"&gt;useSWR&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;useSWR&lt;/code&gt; can help you to reduce parsing states between components, just call &lt;code&gt;useSWR&lt;/code&gt; in anywhere you wish to use the states.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;useSWR&lt;/code&gt; can also help you to reduce duplicated requests and auto-fetch after users' re-focus.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The name “SWR” is derived from stale-while-revalidate, a HTTP cache invalidation strategy popularized by HTTP RFC 5861. SWR is a strategy to first return the data from cache (stale), then send the fetch request (revalidate), and finally come with the up-to-date data.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;To use it, it's quite simple:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import useSWR from 'swr'

function Profile() {
  const { data, error } = useSWR('/api/user', fetcher)

  if (error) return &amp;lt;div&amp;gt;failed to load&amp;lt;/div&amp;gt;
  if (!data) return &amp;lt;div&amp;gt;loading...&amp;lt;/div&amp;gt;
  return &amp;lt;div&amp;gt;hello {data.name}!&amp;lt;/div&amp;gt;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>css</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Reduce Duplicated Styled Components? Check Here</title>
      <dc:creator>Jiawei Li</dc:creator>
      <pubDate>Thu, 24 Mar 2022 05:50:06 +0000</pubDate>
      <link>https://dev.to/zhcalvin/reduce-duplicated-styled-components-check-here-240p</link>
      <guid>https://dev.to/zhcalvin/reduce-duplicated-styled-components-check-here-240p</guid>
      <description>&lt;p&gt;I made a post 2 weeks ago about how to reduce CSS automatically: &lt;a href="https://dev.to/zhcalvin/scan-duplicated-css-4fc0"&gt;Scan Duplicated &amp;amp; Similar CSS&lt;/a&gt; and the github source: &lt;a href="https://github.com/ruilisi/css-checker"&gt;css-checker&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Few days ago, there was an issue asking for styled components support. It's very hard to found few sources about processing styled components using golang, so I have to use regex to detect them and use original css-checker functions to detect diffs in styled-components. &lt;/p&gt;

&lt;p&gt;Fortunately, it goes well to use css-checker for styled-components checking and you can use this now for styled-components check. It can check similar lines and prints those blocks with diff lines highlighted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can access to the package via &lt;code&gt;go install&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go install github.com/ruilisi/css-checker@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(With go version before 1.17, use go get github.com/ruilisi/css-checker). Or download from releases&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Or from npm:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g css-checker-kit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Start Checking
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;cd&lt;/code&gt; to your &lt;code&gt;Project Path&lt;/code&gt;. Then just run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;css-checker -styled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If only need to check styled-components:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;css-checker -css=false -styled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For other usages, please refer to github: &lt;a href="https://github.com/ruilisi/css-checker"&gt;CSS-Checker&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

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

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>opensource</category>
      <category>devops</category>
    </item>
    <item>
      <title>Scan Duplicated &amp; Similar CSS</title>
      <dc:creator>Jiawei Li</dc:creator>
      <pubDate>Fri, 11 Mar 2022 07:01:11 +0000</pubDate>
      <link>https://dev.to/zhcalvin/scan-duplicated-css-4fc0</link>
      <guid>https://dev.to/zhcalvin/scan-duplicated-css-4fc0</guid>
      <description>&lt;p&gt;To auto detect redundant and unused CSS classes, I made this library recently: &lt;a href="https://github.com/ruilisi/css-checker"&gt;css-checker&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It helps to scan your codebase automatically by one command: 'css-checker'. I think it's always better to rely on automatic code checking tools than read all codes manually to find improvements.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;css-check&lt;/code&gt; can scan your CSS code along with your js/jsx/html/ts/tsx code to find unused CSS code (optional). &lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can access to the package via &lt;code&gt;go install&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go install github.com/ruilisi/css-checker@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(With go version before 1.17, use go get github.com/ruilisi/css-checker). Or download from releases&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Or from npm:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g css-checker-kit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Start Checking
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; to your &lt;code&gt;Project Path&lt;/code&gt;. Then just run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;css-checker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H3CEMFaD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ba5i8r86sgb0yyzbqqs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H3CEMFaD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ba5i8r86sgb0yyzbqqs.gif" alt="Image description" width="715" height="767"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;css-checker&lt;/code&gt; helps in checking my projects in seconds, and provides hundreds of similar and redundant classes for me to improve. &lt;/p&gt;

&lt;p&gt;You can check out the package from the Github link for more details:  &lt;a href="https://github.com/ruilisi/css-checker"&gt;css-checker&lt;/a&gt;&lt;/p&gt;

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