<?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: Unresolute</title>
    <description>The latest articles on DEV Community by Unresolute (@unresolute).</description>
    <link>https://dev.to/unresolute</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4262883%2Fa98e8d88-4055-43f2-b12e-288fb5e040d9.png</url>
      <title>DEV Community: Unresolute</title>
      <link>https://dev.to/unresolute</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/unresolute"/>
    <language>en</language>
    <item>
      <title>A browser in 688 KB: what Win32 and WebView2 can still do</title>
      <dc:creator>Unresolute</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:39:11 +0000</pubDate>
      <link>https://dev.to/unresolute/a-browser-in-688-kb-what-win32-and-webview2-can-still-do-1obf</link>
      <guid>https://dev.to/unresolute/a-browser-in-688-kb-what-win32-and-webview2-can-still-do-1obf</guid>
      <description>&lt;p&gt;The browser engine is already on your machine. That sentence is the whole project.&lt;/p&gt;

&lt;p&gt;I wanted a window small enough to keep one page in the corner of the screen — a dashboard, an API&lt;br&gt;
reference, a chat — without keeping a whole browser window there. The options I found were either a&lt;br&gt;
pinned browser window or an Electron mini-browser with an 80–150 MB runtime. So I built the host&lt;br&gt;
myself: &lt;strong&gt;tinybrowser&lt;/strong&gt;, a 160×90 always-on-top browser for Windows in a single &lt;strong&gt;688,640-byte&lt;/strong&gt; exe.&lt;/p&gt;

&lt;p&gt;No Electron. No installer. No VC++ redistributable. C++20, Win32 and the WebView2 runtime that ships&lt;br&gt;
with Edge and Windows 11.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsooojw824l1ugu7ryc3c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsooojw824l1ugu7ryc3c.gif" alt="tinybrowser demo: the window, the colour eyedropper, a .to snapshot and duplicated windows" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The 46-second demo: &lt;a href="https://alainrichell.github.io/tinybrowser/demo.mp4" rel="noopener noreferrer"&gt;demo.mp4&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The engine is not inside the exe
&lt;/h2&gt;

&lt;p&gt;That is the trick, and it is also the trade-off. WebView2 is a system component; the exe is only the&lt;br&gt;
host. It statically links the runtime (&lt;code&gt;/MT&lt;/code&gt;), compiles with &lt;code&gt;/O2&lt;/code&gt;, &lt;code&gt;/OPT:REF&lt;/code&gt; and &lt;code&gt;/OPT:ICF&lt;/code&gt;, and&lt;br&gt;
carries the window, the HTML bar, the gestures, the containers and the snapshot format. That is why&lt;br&gt;
the number is 688 KB and not 80 MB.&lt;/p&gt;

&lt;p&gt;If you want the same idea on macOS or Linux, you need a different host and a different system runtime.&lt;br&gt;
tinybrowser is deliberately Windows-only.&lt;/p&gt;
&lt;h2&gt;
  
  
  One window, one engine, one page
&lt;/h2&gt;

&lt;p&gt;Each tiny window is a real browser: address bar, navigation, zoom, cookies, sessions. It is not a&lt;br&gt;
fixed-URL viewer. There are no tabs on purpose — one page per window, as many windows as you need.&lt;br&gt;
&lt;code&gt;Ctrl+Alt+D&lt;/code&gt; duplicates the current one into the next free spot; &lt;code&gt;Ctrl+click&lt;/code&gt; opens a link in another&lt;br&gt;
one.&lt;/p&gt;

&lt;p&gt;The window has two sizes that belong to the app: a &lt;strong&gt;141×77&lt;/strong&gt; start bar and a &lt;strong&gt;160×90&lt;/strong&gt; page window.&lt;br&gt;
Every page is scaled so its whole width fits; without that, 90 px of height would show one corner of a&lt;br&gt;
desktop layout. The user can resize it by hand down to &lt;strong&gt;60×60&lt;/strong&gt;, and the app leaves that size alone.&lt;/p&gt;
&lt;h2&gt;
  
  
  Per-window containers, without a browser process per container
&lt;/h2&gt;

&lt;p&gt;A container is a separate set of cookies, sessions, storage, cache, permissions and history for the&lt;br&gt;
same window. It is a &lt;strong&gt;WebView2 profile&lt;/strong&gt; inside the same data folder, not a second copy of the&lt;br&gt;
engine. Two Google accounts can stay open at the same time; changing the container reloads that page&lt;br&gt;
in the other profile and keeps the window, size and zoom.&lt;/p&gt;

&lt;p&gt;The same idea makes &lt;code&gt;.to&lt;/code&gt; snapshots possible: a window is frozen into a plain &lt;code&gt;key=value&lt;/code&gt; text file&lt;br&gt;
with its address, rectangle, zoom, container, corners and keyed colours. Double-click it in Explorer&lt;br&gt;
and the window comes back exactly as it was. The file is readable in Notepad; no database, no cloud.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fseiybn9tuork2ccpslth.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fseiybn9tuork2ccpslth.png" alt="tinybrowser's start bar: address field, six buttons and the container name" width="705" height="385"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  The hard parts were all host-side
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Windowed WebView2 cannot be translucent
&lt;/h3&gt;

&lt;p&gt;The colour eyedropper makes a colour transparent to the desktop, including video and canvas. That is&lt;br&gt;
not a CSS background trick: the engine is drawing per-pixel alpha. To get it, the window has to move&lt;br&gt;
from &lt;strong&gt;windowed&lt;/strong&gt; hosting (a child HWND) to &lt;strong&gt;composition&lt;/strong&gt; hosting (a DirectComposition tree). The&lt;br&gt;
host also adds &lt;code&gt;WS_EX_NOREDIRECTIONBITMAP&lt;/code&gt; so the window has no surface of its own, and sets a&lt;br&gt;
transparent default background:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="n"&gt;controller2&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;put_DefaultBackgroundColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;COREWEBVIEW2_COLOR&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The price is that pointer input has to be forwarded by hand, because there is no child HWND to receive&lt;br&gt;
it. The first colour pick recreates the engine, so the page is empty for about a second. That is the&lt;br&gt;
honest cost of per-pixel transparency in WebView2; I did not find a cheaper way.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Rounded corners are a window region, not a frame
&lt;/h3&gt;

&lt;p&gt;Windows 11 has a corner preference, but it gives you a fixed radius — not a 0–100 slider where 100&lt;br&gt;
means “as round as four equal corners can be”. The shape is a Win32 region:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="no"&gt;HRGN&lt;/span&gt; &lt;span class="n"&gt;region&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CreateRoundRectRgn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;height&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                 &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nc"&gt;SetWindowRgn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;TRUE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the system owns the region&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The radius is &lt;code&gt;percentage × shorterSide / 200&lt;/code&gt;, so at 100 a 160×90 window becomes a &lt;strong&gt;capsule&lt;/strong&gt;, not&lt;br&gt;
an ellipse. The part that is easy to miss is the hit test: the low-level mouse hook decides by&lt;br&gt;
rectangle, so a press in the clipped corner would be swallowed and become a resize of a window nobody&lt;br&gt;
can see. The hook has to use the same quarter-circle test:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;inside&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dx&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dy&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;SetWindowRgn&lt;/code&gt; also invalidates the whole window, so the host remembers the last radius and size and&lt;br&gt;
only rebuilds the region when the answer changes. At 0 it does not call it at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The mouse hook is the window manager
&lt;/h3&gt;

&lt;p&gt;The page never sees the scrollbar, and the engine consumes most mouse input. Resizing from any edge,&lt;br&gt;
moving with &lt;code&gt;Alt&lt;/code&gt;+drag and the corner gestures therefore run through a low-level mouse hook. Two&lt;br&gt;
things I had to learn the hard way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;WindowFromPoint&lt;/code&gt; + &lt;code&gt;GetAncestor(hit, GA_ROOT)&lt;/code&gt; is the z-order gate. Without it, an &lt;strong&gt;unpinned&lt;/strong&gt;
window that is covered by another app swallows a click meant for the app in front and resizes
itself behind it. That is the “it shrinks by itself when I click outside it” bug.&lt;/li&gt;
&lt;li&gt;The edge cursor cannot live in a class on &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;: every framework rewrites that attribute on each
render, and the cursor disappears. It lives in a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; element the page owns, rewritten in
place.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Ctrl+click is a WebView2 event, with a real-gesture gate
&lt;/h3&gt;

&lt;p&gt;WebView2 turns Ctrl+click into &lt;code&gt;NewWindowRequested&lt;/code&gt;. The handler used to navigate the same window;&lt;br&gt;
now it opens another tiny window at the same size, in the next free spot, with the same container and&lt;br&gt;
corners, and none of the source window's keyed colours.&lt;/p&gt;

&lt;p&gt;The gate: the low-level hook arms a one-shot flag only when the left button goes down with Ctrl&lt;br&gt;
physically held. A page that calls &lt;code&gt;window.open&lt;/code&gt; on its own finds the flag empty and keeps the old&lt;br&gt;
behaviour. The page script also stops rewriting &lt;code&gt;target="_blank"&lt;/code&gt; to &lt;code&gt;_self&lt;/code&gt; when Ctrl is held;&lt;br&gt;
otherwise the gesture becomes an ordinary navigation before the event can fire.&lt;/p&gt;

&lt;h2&gt;
  
  
  What did not work
&lt;/h2&gt;

&lt;p&gt;Three things looked reasonable and did not survive contact with the engine:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Layered windows&lt;/strong&gt; (&lt;code&gt;WS_EX_LAYERED&lt;/code&gt; + &lt;code&gt;UpdateLayeredWindow&lt;/code&gt;) cannot host WebView2 correctly: the
window alpha does not reach the child HWND, so the page stays opaque.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DWM corner preference&lt;/strong&gt; gives a pleasant fixed rounding, but no slider and no capsule. It is a
Windows 11 look, not a shape control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clipping the page with CSS&lt;/strong&gt; looks fine on a test page but is fragile with real ones: pages paint
their own backgrounds, fixed elements escape the clip, and the transparent corners need composition
anyway. A window region is less glamorous and more predictable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The numbers
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;exe&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;688,640 bytes&lt;/strong&gt;, statically linked C++20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;window&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;160×90&lt;/strong&gt;, minimum &lt;strong&gt;60×60&lt;/strong&gt;, 141×77 start bar&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;engine&lt;/td&gt;
&lt;td&gt;WebView2, already on Windows 10/11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;install&lt;/td&gt;
&lt;td&gt;none; copy the exe, delete the exe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;containers&lt;/td&gt;
&lt;td&gt;per window, WebView2 profiles in one data folder&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;snapshots&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;.to&lt;/code&gt;, plain text, double-click to reopen&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;demo&lt;/td&gt;
&lt;td&gt;46 s, 60 fps&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What it is not
&lt;/h2&gt;

&lt;p&gt;It is not a replacement for your browser. There are no tabs, it is Windows-only, and the exe is&lt;br&gt;
unsigned, so SmartScreen warns on the first run. It needs the WebView2 runtime, which ships with Edge&lt;br&gt;
and Windows 11; on a machine without it, the app offers to install it.&lt;/p&gt;

&lt;p&gt;It is also not free of renderer memory: each window still has a WebView2 renderer. The win is the&lt;br&gt;
host — no Electron runtime, no installer, no account, no telemetry — and the shape of the window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Download:&lt;/strong&gt; &lt;a href="https://github.com/AlainRichell/tinybrowser/releases/latest" rel="noopener noreferrer"&gt;tinybrowser.exe&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source:&lt;/strong&gt; &lt;a href="https://github.com/AlainRichell/tinybrowser" rel="noopener noreferrer"&gt;github.com/AlainRichell/tinybrowser&lt;/a&gt; (MIT)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Site:&lt;/strong&gt; &lt;a href="https://alainrichell.github.io/tinybrowser/" rel="noopener noreferrer"&gt;alainrichell.github.io/tinybrowser&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try it, I would like to know what you keep in a 160×90 window — and what breaks on your setup.&lt;br&gt;
Multi-monitor and 150% DPI are the two places I expect the most interesting bugs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I used AI assistance for parts of the implementation and this write-up. The design&lt;br&gt;
decisions, the testing and the app are mine.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>microsoft</category>
      <category>cpp</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
