<?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"><channel><title><![CDATA[YT to MP4 Engineering]]></title><description><![CDATA[YT to MP4 Engineering]]></description><link>https://yttomp4.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 09:23:47 GMT</lastBuildDate><atom:link href="https://yttomp4.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How we keep a 10-language tool site fast without a framework]]></title><description><![CDATA[YT to MP4 is a free YouTube to MP4 converter in 10 languages. Most of its visitors arrive on a phone, often on mobile data, and they want one thing: paste…]]></description><link>https://yttomp4.hashnode.dev/how-we-keep-a-10-language-tool-site-fast-without-a-framework</link><guid isPermaLink="true">https://yttomp4.hashnode.dev/how-we-keep-a-10-language-tool-site-fast-without-a-framework</guid><category><![CDATA[Web Development]]></category><category><![CDATA[performance]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[YT to MP4]]></dc:creator><pubDate>Mon, 23 Nov 2026 10:08:07 GMT</pubDate><content:encoded><![CDATA[<p><a href="https://yt-to-mp4.net/">YT to MP4</a> is a free YouTube to MP4 converter in 10 languages. Most of its visitors arrive on a phone, often on mobile data, and they want one thing: paste a link and get a file. If the page is slow, they go back to Google and click the next result.</p>
<p>So speed is the feature. The homepage is about 48 KB of HTML, it is built to score 95+ on Lighthouse, and the layout doesn't shift while it loads. None of that needed a framework. It came from a handful of small decisions in the build script. Here they are.</p>
<h2>1. The CSS lives inside the HTML</h2>
<p>The whole stylesheet is about 23 KB after minifying, small enough to inline in a <code>&lt;style&gt;</code> tag in every page. That removes a render-blocking request. The browser can paint the first screen with the first response, which matters most on a slow connection where every extra round trip costs hundreds of milliseconds.</p>
<p>The trade-off is that CSS isn't cached separately between pages. For a site where most visitors use one page and leave with their file, that is the right trade.</p>
<p>The minifier is a few regular expressions in the build, not a dependency:</p>
<pre><code class="language-js">const minCss = (css) =&gt; css
  .replace(/\/\*.*?\*\//gs, "")
  .replace(/\s*\n\s*/g, "")
  .replace(/\s*([{};,&gt;])\s*/g, "$1")
  .replace(/;}/g, "}");
</code></pre>
<h2>2. One font, one subset, and not for every language</h2>
<p>The design uses one custom font. It is a single variable font file of about 34 KB that covers every weight, cut down to the Latin characters only. Three rules keep it from slowing anything down:</p>
<ul>
<li><strong><code>font-display: optional</code></strong>. If the font isn't ready almost immediately, the browser keeps the system font for that page view instead of swapping later. No flash of changing text, and no layout shift from a font that is wider or narrower than the fallback.</li>
<li><strong><code>unicode-range</code></strong>. The browser only downloads the file if the page actually uses characters in that range.</li>
<li><strong>No font at all where it can't help.</strong> The Latin subset has no Arabic, Devanagari or Vietnamese characters, and the Turkish pages need letters it doesn't include either. So the Arabic, Hindi, Turkish and Vietnamese pages don't preload the font. They use the system font, which already looks right for those scripts.</li>
</ul>
<p>In the build, that is one list per site:</p>
<pre><code class="language-js">const LOOK = {
  mp4: {
    fonts: [["mp4-sora-latin.woff2", "/type/sora.woff2", null]],
    noFont: ["ar", "hi", "tr", "vi"],
  },
};
</code></pre>
<p>Pages that do use the font get a <code>&lt;link rel="preload"&gt;</code> for it, so the request starts while the HTML is still being parsed.</p>
<h2>3. JavaScript only where there is a tool</h2>
<p>The converter script is about 32 KB, loaded with <code>defer</code>, so it never blocks rendering. Pages without a tool on them, like the privacy policy, don't load it at all.</p>
<p>The file name includes a hash of its contents, for example <code>convert.3f9a1c2b7e.js</code>. That means browsers can cache it for a long time, and a new deploy automatically gets a new name, so nobody ever runs a stale script against a newer page.</p>
<h2>4. Analytics waits its turn</h2>
<p>Analytics scripts are one of the most common reasons small sites fail Core Web Vitals. Here, the tag isn't in the HTML at all. A tiny inline snippet sets consent defaults first (analytics storage is denied by default for visitors in Europe), then waits until the page has fully loaded, plus another 1.2 seconds, before inserting the analytics script.</p>
<pre><code class="language-js">addEventListener("load", () =&gt; {
  setTimeout(() =&gt; {
    const s = document.createElement("script");
    s.async = true;
    s.src = "https://www.googletagmanager.com/gtag/js?id=...";
    document.head.appendChild(s);
  }, 1200);
});
</code></pre>
<p>The cost is that a visitor who leaves within the first second isn't counted. For a speed-first tool site, that is an easy trade.</p>
<h2>5. Small things that add up</h2>
<ul>
<li><strong><code>preconnect</code> to the thumbnail host.</strong> As soon as someone pastes a link, the page shows the video thumbnail. Opening the connection to the image host early makes that thumbnail appear noticeably faster.</li>
<li><strong>Fixed sizes on every image.</strong> Thumbnails have <code>width</code> and <code>height</code> set, so the result card never jumps when the image arrives. That is most of the reason layout shift stays at zero.</li>
<li><strong>An offline page.</strong> A tiny service worker caches one page, and only for navigations. If someone opens the site in a dead zone, they get "You're offline, try again" instead of the browser's error screen. API calls and downloads always go to the network.</li>
<li><strong>One HTML file per URL.</strong> Every page is pre-built, so nginx serves a static file. There is no server rendering on the request path.</li>
</ul>
<h2>What I'd tell anyone building a small tool site</h2>
<p>Measure on a mid-range phone with network throttling, not on your laptop. Most of the wins above are invisible on fast Wi-Fi and obvious on a slow connection, which is exactly where your users are.</p>
<p>You can see the result on <a href="https://yt-to-mp4.net/">YT to MP4</a>. Paste any YouTube or Shorts link and the whole flow, from page load to file, runs on the setup described here.</p>
]]></content:encoded></item></channel></rss>