<?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: Thanh Dat Vo</title>
    <description>The latest articles on DEV Community by Thanh Dat Vo (@vo9312).</description>
    <link>https://dev.to/vo9312</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%2F447015%2Ff1e003bd-ba1d-4980-9f61-feeb6f340070.jpeg</url>
      <title>DEV Community: Thanh Dat Vo</title>
      <link>https://dev.to/vo9312</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vo9312"/>
    <language>en</language>
    <item>
      <title>A small Vite plugin for moving heavy JSX attributes into comments</title>
      <dc:creator>Thanh Dat Vo</dc:creator>
      <pubDate>Sun, 10 May 2026 06:21:28 +0000</pubDate>
      <link>https://dev.to/vo9312/a-small-vite-plugin-for-moving-heavy-jsx-attributes-into-comments-21dn</link>
      <guid>https://dev.to/vo9312/a-small-vite-plugin-for-moving-heavy-jsx-attributes-into-comments-21dn</guid>
      <description>&lt;p&gt;Hi everybody,&lt;br&gt;
I'm a software engineer for as long as I can remember.&lt;/p&gt;

&lt;p&gt;When working with web application frameworks, I often get tired when having to scan long JSX, mostly because of long class names.&lt;/p&gt;

&lt;p&gt;I had an idea of writing a Vite plugin that move the classname attributes into comments above element. &lt;br&gt;
For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"rounded-lg bg-blue-500 px-4 py-2 text-white"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello Mom&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;After
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* @class rounded-lg bg-blue-500 */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* @class px-4 py-2 text-white */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello Mom&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;Beside making JSX shorter and easier to scan, this also let you try new attribute values during development while keeping the original JSX unchanged. &lt;br&gt;
For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* @class rounded-lg bg-blue-500 */&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello Mom&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;You can try them online:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackblitz.com/github/thanhdatvo/vite-plugin-comment-attrs/tree/main/examples/react?file=src%2FApp.after.tsx" rel="noopener noreferrer"&gt;React playground&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackblitz.com/github/thanhdatvo/vite-plugin-comment-attrs/tree/main/examples/solid?file=src%2Fapp.after.tsx" rel="noopener noreferrer"&gt;Solid playground&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please switch between &lt;code&gt;App.before.tsx&lt;/code&gt; and &lt;code&gt;App.after.tsx&lt;/code&gt; to compare the syntax&lt;/p&gt;




&lt;p&gt;I’d love feedback from JSX users:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this syntax useful?&lt;/li&gt;
&lt;li&gt;Would you use this in real projects?&lt;/li&gt;
&lt;li&gt;What directives should be supported by default? &lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;This is the &lt;a href="https://github.com/thanhdatvo/vite-plugin-comment-attrs" rel="noopener noreferrer"&gt;plugin repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Issues, ideas, and pull requests are welcome.&lt;/p&gt;

&lt;p&gt;Thank you for taking a look!&lt;/p&gt;

</description>
      <category>vite</category>
      <category>jsx</category>
      <category>react</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
