<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vasanth M on Medium]]></title>
        <description><![CDATA[Stories by Vasanth M on Medium]]></description>
        <link>https://medium.com/@VaZark?source=rss-3fe2d162619b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*p5KzRUwivkn5WvpM.jpg</url>
            <title>Stories by Vasanth M on Medium</title>
            <link>https://medium.com/@VaZark?source=rss-3fe2d162619b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 15:43:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@VaZark/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A case for native HTML partials]]></title>
            <link>https://medium.com/@VaZark/a-case-for-native-html-partials-8794d64f614e?source=rss-3fe2d162619b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8794d64f614e</guid>
            <category><![CDATA[web-standards]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Vasanth M]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 20:23:47 GMT</pubDate>
            <atom:updated>2023-08-27T20:23:47.150Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Is it time we extend HTML for the modern web ?</blockquote><h4><strong>The Problem</strong></h4><p>In recent years, the frontend has become more stateful and driven by JS-first frameworks that allowed the UI concerns to be self-contained and pushing the backend to be an API server instead of fullstack webserver. However, we are currently are seeing the return of server-rendered frameworks.</p><p>These new JS frameworks seem to be re-implementing and re-discovering pitfalls handled by mature framework like django and laravel. That being said, while the functionality offered are similar, they are not reimplementing the exact same logic.</p><h4>Is there a difference ?</h4><p>I’d like to differentiate the new framework like Next vs a classic framework like django in their approach to solve the same problem.</p><p>In django/laravel SSR, at the end of a request cycle, the resulting data is passed to a HTML template which generates the HTML for the request. I’d like to call them <em>backend-first fullstack</em> frameworks.</p><p>This is in stark contrast with <em>frontend-first fullstack</em> frameworks like Next where the UI (react) is the primary priority and the function/API called via REST/rpc/server actions are secondary concerns.</p><p>Neither approach is particularly wrong/right. The rise of React redefined how we thought of our UIs, both browers &amp; mobile apps. We got <em>Declarative components </em>— little self-descriptive and isolated pieces of code for a particular feature</p><p>This continues to be the biggest advantage of <em>frontend-first fullstack frameworks</em> that use components everywhere to be user-first when designing a webapp. Meanwhile backend frameworks continue to treat UI concerns to be an afterthought since they deal exclusively with the data nowadays.</p><p>So are the backend-first frameworks meant to be relegated to the trashcan ? Is the are no way for the two co-exist ? Or be improved upon ?</p><h4>My problem with frontend-first fullstack frameworks</h4><p><strong><em>None.</em></strong></p><p>However, I do find it tiring that one has to serve up an entire site that runs on React/Vue/angular when the part of the site that profits from the virtual DOM interactivity is a tiny fraction of it.</p><p>Frontend developers have to jump through hoops of state management , VDOM re-rendering, state caching across parents, children and siblings (not to mention a million npm libs) just to update a tiny section of the code on a page. We seem to be recreating bootstrap + a few custom utilities with just a different API adapted to your framework of choice.</p><blockquote><strong>Disclaimer</strong> : This is not the case for complex frontends that require high-levels of interactivity like google maps, Sheets or GrapeJS. However, most sites are i18n-enabled a11y-friendly interfaces while the critical business logic resides on the backend (be it a server/serverless).</blockquote><p>I’d like to see the vanilla HTML/CSS given their proper dues and be utilised to their fullest instead of being the result of a gazilion VDOM comparisons on the JS.</p><h4>Web components : The game changer that never was</h4><p>In a move to standardize declarative components, the web component standard evolved. While it perfectly does replicate the idea of a component, developers still need to write the logic manually for each component and thus it ended in the big buckets of frameworks instead of ending the framework wars.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*uWcBOnd511vvSpIV" /></figure><p>My personal disfavour of webcomponents arises from the fact that it did not give us a target to compile to like vanilla HTML/CSS/JS. It does not extend the HTML experience itself and was an ancillary extension that we have to implement manually for each case or be automated by frameworks like angular defeating their purpose.</p><p>In my limited work with them, webcomponents were particularly useful to replace iframes with official interactive components that can be used by partners rather than be an building blocks of our website.</p><h3>Partials &amp; Templates</h3><p>One of the core feature of this proposal intends to improve stateless HTML frontend by providing clear targets for both the frontend-first and backend-first frameworks to generate. So what is this miracle solution ? <em>Partials</em></p><p>Anyone who has developed sites in the early days of nodeJS can attest to handlebarsJS was pretty fun to use. Especially since it allowed both client and server-side templating. I revisited this old friend after stumbling across HTMX recently that makes a good case that Hypermedia needs to step up for a simpler (but not simple) developer experience.</p><p><em>Advantages</em></p><p>For client-side templating, each template with slot can be component / sub-component that can interact with each other providing sandboxing but also trigger events for the global dom tree. Thus, it still allows you to build and test frontend independently by mocking server response. So you can build static sites withouts compromising interactivity.</p><p>For server-side rendering, this plays nice with existing HTML renderers like jinja2. backend-first frameworks can choose to extend the main layout or render only the partial based on the partial-target request header. Building UI can be modularised and these components can be shared across pages and projects without reinventing the wheel.</p><p>So here is my proposal that arose from mixing handlebars, web components &amp; htmx.</p><h3>Proposal</h3><p><em>New Features</em></p><ol><li>A new tag : &lt;partial&gt; with attributes <em>accepts-encoding</em> and <em>uses</em> (accepts id of a template)</li><li>New API Function : <em>setPartialFromResponse</em></li><li>Client side : templates and slots</li><li>Server side : Allow <em>text/html-fragment</em> as new content disposition type</li><li>New response header <em>partial-target</em>: semicolon-separated classnames and tag id with insertion types : replace, beforeend, afterend, beforebegin &amp; afterbegin (Similar to <em>insertAdjancentSibling A</em>PI)</li><li>New optional request header <em>partial-target</em></li><li>Optional (but sweet) extensions : New attribute <em>partial-target</em> to be set on the header with form &amp; a tags</li></ol><h4>Functional User story</h4><p>1. When a page is loaded, all content within the partial tag is renderer as usual.</p><p>2. In an ajax call, when request header with partial-target is set, define a convention for server to echo the header (it can be overriden if required)</p><p>3. After getting the response from the server, dev can invoke <em>setPartialFromResponse</em>.</p><p>4. <em>setPartialFromResponse</em> must run in different ways based on the content-type</p><p>5. When a form request or a hyperlink with partial-target, the browser waits for the response and if response content is a html <em>documentfragment</em> or a JSON, automaticallly run <em>setPartialFromResponse</em> API</p><p><strong>setPartialFromResponse behaviours</strong></p><p>1. In the content disposition, it must find the matching HTML tag(s) (.target or #target or #target1;.target-class)</p><p><em>text/html-fragment</em></p><p>Replace the HTML with the response after parsing the data</p><p><em>application/json</em></p><ol><li>If there is a no uses attribute on the target, convert it to text and set it on the target</li><li>If there is a uses attribute on the target, get the template with the ID that matches.</li></ol><p><strong><em>Inserting data into template slots</em></strong></p><ol><li>On parsing the data, get the keys and look for matches in slot names</li><li>Insert as is, if data is primitive (int, str)</li><li>Insert as is, if slot name is explicit for a nested object or arrays (“key.subkey”, “key[0].subkey”)</li><li>In case of arrays with dynamic sizes and a nested object , the corresponding slot must be another partial</li></ol><h4>Use cases</h4><ol><li>In-page SPA-like routing</li><li>Native combobox ? (or atleast a dynamic datalist)</li><li>Real HTML-first components with isolated (optional) JS bundling</li><li>Leaner web pages Out-of-the-box with only required components</li></ol><h4>Conclusion</h4><p>I plan building a simple library based on these features proposals to see far I can take it.</p><p>It would be great if these ideas can be looked over by someone who works closely with the standards committee and refine/reuse or be inspired by these ideas &amp; upstream them, so that someday we have simpler targets , smaller builds and easier refactorings. It’s time for hypermedia to step up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8794d64f614e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>