Hardware

Bun 1.4 Introduces Bun.WebView for Browser Automation

The release of Bun 1.4 introduces an experimental Bun.WebView API, enabling developers to run browser automation and capture screenshots without heavy dependencies like Puppeteer.

Simon Willison2 days agoHardware
Illustration generated for this story

The launch of Bun 1.4 marks the first stable release of the JavaScript runtime since its transition from Zig to Rust. Alongside 2,900 bug fixes and 1,517 new tests from the Node.js test suite, the update boasts significant performance improvements, including a fivefold reduction in idle CPU usage, up to a 35 percent reduction in memory consumption, and 50 percent faster startup times on Linux. Among the newly introduced APIs, Bun.WebView stands out by bringing native browser automation directly to the runtime core.

Bun.WebView allows developers to control macOS WebKit or a local Chromium process using the Chrome DevTools Protocol. To test this capability, developer Simon Willison used Claude Code to build a lightweight, zero-dependency prototype. The resulting 150-line TypeScript service acts as a JSON API that can evaluate JavaScript and capture screenshots in PNG, JPEG, or WebP formats. Crucially, this setup bypasses the need for heavy external orchestration libraries like Puppeteer or Playwright.

The prototype service handles concurrency by opening a single browser tab per incoming request, serving endpoints like /javascript, /screenshot, and /healthz. Testing the system within cgroups revealed that running a full Chromium instance against complex web pages requires a container with only 192MB to 256MB of RAM.

For software engineers and system architects, this development drastically simplifies the deployment of web scraping and automated testing tools. By embedding browser control directly into the runtime, Bun 1.4 eliminates the complex dependency chains and heavy memory overhead typically associated with headless browser automation. Developers can now deploy highly efficient, concurrent scraping microservices in lightweight container environments at a fraction of the traditional resource cost.

This is our own summary of reporting by Simon Willison

More in Hardware