<?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: physical</title>
    <description>The latest articles on DEV Community by physical (@physicalaff).</description>
    <link>https://dev.to/physicalaff</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%2F3947650%2F47a0bc8a-a63e-42fe-af76-65dd8505ef28.jpeg</url>
      <title>DEV Community: physical</title>
      <link>https://dev.to/physicalaff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/physicalaff"/>
    <language>en</language>
    <item>
      <title>How I built a Chrome extension that runs Stockfish using WebAssembly (fully local chess analysis)</title>
      <dc:creator>physical</dc:creator>
      <pubDate>Fri, 05 Jun 2026 17:37:32 +0000</pubDate>
      <link>https://dev.to/physicalaff/how-i-built-a-chrome-extension-that-runs-stockfish-using-webassembly-fully-local-chess-analysis-5gkp</link>
      <guid>https://dev.to/physicalaff/how-i-built-a-chrome-extension-that-runs-stockfish-using-webassembly-fully-local-chess-analysis-5gkp</guid>
      <description>&lt;h1&gt;
  
  
  How I built a Chrome extension that runs Stockfish using WebAssembly
&lt;/h1&gt;

&lt;p&gt;Recently I experimented with running a full chess engine directly inside the browser, without any backend services.&lt;/p&gt;

&lt;p&gt;The result is a Chrome extension that runs Stockfish locally using WebAssembly.&lt;/p&gt;

&lt;p&gt;This post is a breakdown of how it works, why I built it, and what challenges I ran into.&lt;/p&gt;




&lt;h1&gt;
  
  
  🚀 Motivation
&lt;/h1&gt;

&lt;p&gt;I wanted to explore a simple question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How far can we push browser-based computation today?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Specifically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can a chess engine run fully in the browser?&lt;/li&gt;
&lt;li&gt;How viable is WebAssembly for CPU-heavy workloads?&lt;/li&gt;
&lt;li&gt;What limitations does Chrome Extensions (Manifest V3) introduce?&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  🧠 Architecture overview
&lt;/h1&gt;

&lt;p&gt;The system is built around three main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stockfish compiled to WebAssembly&lt;/li&gt;
&lt;li&gt;Chrome Extension (Manifest V3)&lt;/li&gt;
&lt;li&gt;Message-based communication between extension contexts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything runs locally — there is no backend, no API calls, no server-side logic.&lt;/p&gt;




&lt;h1&gt;
  
  
  ⚙️ How it works
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1. WebAssembly Stockfish
&lt;/h3&gt;

&lt;p&gt;The Stockfish engine is compiled into WebAssembly so it can run inside the browser runtime.&lt;/p&gt;

&lt;p&gt;This allows near-native performance for heavy computation tasks.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Chrome Extension (MV3)
&lt;/h3&gt;

&lt;p&gt;The extension is structured using Manifest V3:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Background service worker&lt;/li&gt;
&lt;li&gt;Content scripts&lt;/li&gt;
&lt;li&gt;UI popup&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One of the main challenges is that service workers are not persistent, which affects how long-running computations must be handled.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Communication layer
&lt;/h3&gt;

&lt;p&gt;Because of MV3 constraints, the architecture relies heavily on message passing between:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;UI → background&lt;/li&gt;
&lt;li&gt;background → engine&lt;/li&gt;
&lt;li&gt;engine → UI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Designing this cleanly was more important than raw performance.&lt;/p&gt;




&lt;h1&gt;
  
  
  ⚡ Challenges
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1. Extension lifecycle (MV3)
&lt;/h3&gt;

&lt;p&gt;Service workers can be terminated at any time, so you cannot rely on persistent execution.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. WASM initialization cost
&lt;/h3&gt;

&lt;p&gt;Loading and initializing Stockfish takes noticeable time, so startup optimization matters.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Performance vs responsiveness
&lt;/h3&gt;

&lt;p&gt;Running a chess engine can easily block the UI if not handled carefully.&lt;/p&gt;




&lt;h1&gt;
  
  
  📊 What I learned
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;WebAssembly is already production-ready for CPU-heavy tasks&lt;/li&gt;
&lt;li&gt;Architecture matters more than raw computation speed in browser apps&lt;/li&gt;
&lt;li&gt;Chrome Extensions introduce real constraints that affect system design&lt;/li&gt;
&lt;li&gt;Most complexity comes from lifecycle + messaging, not the engine itself&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  📦 Source code
&lt;/h1&gt;

&lt;p&gt;GitHub:&lt;br&gt;
&lt;a href="https://github.com/physicalaff/Knight-Chess-Helper" rel="noopener noreferrer"&gt;https://github.com/physicalaff/Knight-Chess-Helper&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  🧩 Conclusion
&lt;/h1&gt;

&lt;p&gt;This was more of an experiment than a product.&lt;/p&gt;

&lt;p&gt;It helped me understand how far modern browsers can go when pushed beyond typical web app workloads.&lt;/p&gt;

&lt;p&gt;If you’ve worked with WebAssembly or Chrome Extensions, I’d be curious how you handled similar constraints.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>webassembly</category>
      <category>stockfish</category>
      <category>chess</category>
    </item>
    <item>
      <title>Building a High-Performance Local Chess Assistant Extension with WebAssembly Stockfish and Manifest V3</title>
      <dc:creator>physical</dc:creator>
      <pubDate>Sat, 23 May 2026 12:21:44 +0000</pubDate>
      <link>https://dev.to/physicalaff/building-a-high-performance-local-chess-assistant-extension-with-webassembly-stockfish-and-manifest-2ibd</link>
      <guid>https://dev.to/physicalaff/building-a-high-performance-local-chess-assistant-extension-with-webassembly-stockfish-and-manifest-2ibd</guid>
      <description>&lt;p&gt;Hey everyone! 👋&lt;/p&gt;

&lt;p&gt;I wanted to share a project I’ve been working on recently: Knight - Chess Helper. It’s an advanced browser extension designed to assist and analyze chess games on Chess.com entirely locally and in real-time.&lt;/p&gt;

&lt;p&gt;Building a tool like this within the constraints of modern browser security policies (Manifest V3) was a massive technical challenge, and I’d love to walk you through how I solved it.&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.amazonaws.com%2Fuploads%2Farticles%2F647q19dj9ovxburgc9nb.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.amazonaws.com%2Fuploads%2Farticles%2F647q19dj9ovxburgc9nb.png" alt=" " width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;👉 Check out the full repository here: &lt;a href="https://github.com/physicalaff/Knight-Chess-Helper" rel="noopener noreferrer"&gt;https://github.com/physicalaff/Knight-Chess-Helper&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🛠️ The Technical Challenge: Bypassing CSP &amp;amp; Sandboxing&lt;/p&gt;

&lt;p&gt;Modern platforms like Chess.com use very strict Content Security Policies (CSP). You cannot simply inject an external engine script or make third-party server calls to evaluate a board position without triggering security blocks.&lt;br&gt;
To solve this, Knight runs entirely offline and locally using a multi-layered Manifest V3 messaging system:&lt;/p&gt;

&lt;p&gt;The Core Logic: Powered by an optimized local Stockfish WebAssembly (WASM) engine.&lt;br&gt;
The Bridge: Since Manifest V3 background service workers don't support heavy WASM environments directly in some configurations, the extension utilizes Chrome's Offscreen Document API (and native background workers in Firefox) to run the engine inside an isolated, secure offline process.&lt;br&gt;
The UI Layer: A premium, custom glassmorphic dashboard panel injected directly into the active tab that updates hints instantly on click with zero cooldown.&lt;/p&gt;

&lt;p&gt;🧠 Emulating Human-Like Behavior&lt;/p&gt;

&lt;p&gt;One of the most interesting parts of this project was moving away from "robotic" engine play. To make the assistant truly feel like a human companion, I implemented mathematical models to simulate organic human flaws and constraints:&lt;br&gt;
Mouse Movement 2.0: Generates smooth Bezier curves with simulated physical hand micro-tremors.&lt;br&gt;
Emulated Fatigue: Thinking times automatically scale and slow down by 2.5% per turn as the game progresses past move 15, mimicking natural mental exhaustion.&lt;br&gt;
Calculated Misclicks: A built-in small percentage chance to click a neighboring square first, pause in hesitation, cancel, and then correct the move.&lt;br&gt;
Opening Book Integration: Automatically fetches and executes the first 14 half-moves smoothly using the Lichess Masters Database.&lt;br&gt;
🎨 Advanced Presets &amp;amp; ELO Scaling&lt;/p&gt;

&lt;p&gt;The extension features a mathematically calibrated preset matrix. Users can manually scale the assistant from 1000 to 1500 ELO, which dynamically adjusts engine depth, mistake chances, blunder rates, and average thinking variance in real-time.&lt;br&gt;
There is even a hidden ZXC / Shadow Fiend Mode that overhauls the entire UI into a dark-matte neon-red design, complete with an active animated avatar and audio synchronization.&lt;/p&gt;

&lt;p&gt;📂 Source Code &amp;amp; Feedback&lt;br&gt;
The project is completely open-source and licensed under the MIT License. If you are interested in Chrome Extension development, WebAssembly integration, or advanced content script messaging, feel free to check out the codebase!&lt;br&gt;
⭐ Repository: &lt;a href="https://github.com/physicalaff/Knight-Chess-Helper" rel="noopener noreferrer"&gt;https://github.com/physicalaff/Knight-Chess-Helper&lt;/a&gt;&lt;br&gt;
I would highly appreciate your feedback, code reviews, or a ⭐ on GitHub if you find the architecture interesting! What do you think about running heavy WASM engines directly inside browser extensions? Let's discuss in the comments!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webassembly</category>
      <category>webdev</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
