browser
Lightpanda Browser
The headless browser built from scratch for AI agents and automation.
Not a Chromium fork. Not a WebKit patch. A new browser, written in Zig.
Lightpanda: the headless browser designed for AI and automation
Lightpanda:一个不想当“Chromium 影子”的无头浏览器
Lightpanda 的仓库描述像一张名片——短,但一击即中:
Lightpanda: the headless browser designed for AI and automation
他不是为了“再造一个能看网页的东西”而来,他更像为 AI 代理、自动化脚本、LLM 训练、爬取与测试而生的专业选手:轻装、快跑、少吃内存、启动即走。
而 README 开头那段自我介绍,更像他站在舞台中央,抬手就把身世说清楚:
- The headless browser built from scratch for AI agents and automation.
- Not a Chromium fork. Not a WebKit patch.
- A new browser, written in Zig.
他像在说:
“别把我当成大象的切片,我是从零开始长出来的。”
他做什么:为 headless usage 而生的开源浏览器
Lightpanda 把自己定义成“为无头使用而做的开源浏览器”,并且把能力列得很实在:
- JavaScript execution
- Support of Web APIs (partial, WIP)
- Compatible with Playwright[^1]、Puppeteer、chromedp(通过 CDP:Chrome DevTools Protocol)
于是他像一个能“跑 JS、懂 Web API、会说 CDP 方言”的角色:
你给他一个地址,他能加载、执行���请求、渲染 DOM 树(至少在 headless 所需范围内),并且能用现有生态工具链把他接起来。
他为什么要出现:因为现代 Web,离不开 JavaScript
Lightpanda 在 README 里讲“Why?”时,语气很像一个忍了很久的人终于开口:
JavaScript execution is mandatory for the modern web
过去你用 cURL 发个请求就能抓到网页;现在不行了,因为 JavaScript 到处都是:
- Ajax、SPA、无限加载、“点击显示”、即时搜索……
- React、Vue、Angular 等前端框架……
他像在说:
“你想抓网页?你必须能跑 JS。”
但他也很清醒:Chrome 不是正确的工具
既然要跑 JavaScript,为什么不直接跑 Chrome?
Lightpanda 在 README 里列了那三个“痛点”,像给 Chromium 的无头方案写了一封投诉信:
- Heavy:吃 RAM、吃 CPU,跑起来贵
- Hard:打包难、部署难、规模化维护难
- Bloated:功能太多,很多对 headless 根本没用
然后他给出自己的“出身理由”:
Lightpanda is built for performance
要同时要 JavaScript + performance,那就从零开始:
- Not based on Chromium / Blink / WebKit
- 用 Zig 这种低层系统语言,目标是更好优化
- Opinionated:without graphical rendering(专注 headless)
他像一个一心练短跑的人:
不背负桌面浏览器的沉重包袱,只为了“跑得快、跑得稳、跑得省”。
他擅长的场景:AI、自动化、训练、爬取、测试
README 里把他的优势写��很“工程化”:
- Ultra-low memory footprint(9x less than Chrome)
- Exceptionally fast execution(11x faster than Chrome)
- Instant startup
你可以把他想象成一个“看起来瘦、但爆发力极强”的无头浏览器:
脚本一叫就来,跑完就走,不拖泥带水。
Quick start:让他在你的机器上醒来
Lightpanda 的“上手方式”非常终端范儿:拿二进制、加执行权限、直接跑。
Install:从 nightly builds 安装
你可以从 nightly builds 下载最新二进制(Linux x86_64、macOS aarch64)。
For Linux
1 | curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/nightly/lightpanda-x86_64-linux && \ |
For macOS
1 | curl -L -o lightpanda https://github.com/lightpanda-io/browser/releases/download/nightly/lightpanda-aarch64-macos && \ |
For Windows + WSL2
他也愿意在 Windows 世界里出现,但更倾向在 WSL 里跑:
Lightpanda 浏览器可在 WSL 内运行,安装按 Linux 的方式走;同时建议把 Puppeteer 之类的客户端装在 Windows host 上。
Install:用 Docker 把他直接装进容器
Lightpanda 提供官方 Docker 镜像(Linux amd64 / arm64),并且一条命令就把 CDP server 暴露在 9222:
1 | docker run -d --name lightpanda -p 9222:9222 lightpanda/browser:nightly |
他像一个“随时可启动的服务”:���纠结环境,起容器就能连。
让他干活:抓一个 URL,或者开一个 CDP server
Dump a URL(直接抓网页)
1 | ./lightpanda fetch --obey_robots --log_format pretty --log_level info https://demo-browser.lightpanda.io/campfire-commerce/ |
Lightpanda 的输出日志像“边跑边播报”的小助手,会告诉你它在导航、在执行脚本、在发起请求、请求是否成功……最后吐出 HTML(示例里以 <!DOCTYPE html> 结尾)。
Start a CDP server(把他变成可连接的无头浏览器服务)
1 | ./lightpanda serve --obey_robots --log_format pretty --log_level info --host 127.0.0.1 --port 9222 |
一旦 CDP server 跑起来,你就可以用熟悉的生态去连接他,比如 Puppeteer。
和 Puppeteer 牵手:让脚本通过 CDP 连接他
Lightpanda 很清楚:你不想换工具链,你只是想换“更轻更快的浏览器内核”。
所以他给你一个连接示例:把 browserWSEndpoint 指向他的 CDP websocket。
1 |
|
他像在说:
“你继续用 Puppeteer 的语法,我只负责把执行快一点、内存省一点。”
Telemetry:他会记录使用情况,但也给你关门的钥匙
Lightpanda 默认会收集并发送 usage telemetry。
如果你不想要,可以用环境变量关掉:
LIGHTPANDA_DISABLE_TELEMETRY=true
隐私政策地址也给得很直接:
https://lightpanda.io/privacy-policy
Status:他还在 Beta,但已经能跑起来了
Lightpanda 坦诚地说自己还在 Beta、仍在持续完善:
- 稳定性与覆盖面在提升
- 很多网站已经能工作
- 仍可能遇到错误或崩溃(欢迎提 issue)
他还把“已经实现的关键特性”列出来,像一份逐项打勾的进度表:
- HTTP loader(Libcurl)
- HTML parser(html5ever)
- DOM tree
- JavaScript support(v8)
- DOM APIs
- Ajax:XHR API、Fetch API
- DOM dump
- CDP/websockets server
- Click
- Input form
- Cookies
- Custom HTTP headers
- Proxy support
- Network interception
- Respect
robots.txt(可选--obey_robots)
他也提醒:Web API 数量巨大,做浏览器(哪怕只是 headless)也是巨大的工程,覆盖会随时间增加。
同时,你也可以关注他们 JavaScript 支持的进展:zig-js-runtime 项目。
Build from source:如果你想亲手“养”一只 Lightpanda
Prerequisites
Lightpanda 用 Zig 0.15.2 编写,并且依赖:
- zig-js-runtime(带 v8)
- Libcurl
- html5ever
为了能给 zig-js-runtime 构建 v8,你还需要一些系统依赖。
Debian/Ubuntu base Linux
1 | sudo apt install xz-utils ca-certificates \ |
还需要安装 Rust(用于某些依赖链路)。
Nix
1 | nix develop |
macOS
1 | brew install cmake |
并且也需要 Rust。
Build and run:make 或 zig build run
你可以用:
make build(或make build-dev)- 或直接
zig build run
Embed v8 snapshot:把 v8 snapshot “烘焙”进去
Lightpanda 支持 v8 snapshot。默认启动会创建,但你也可以手动嵌入:
生成 snapshot:
1 | zig build snapshot_creator -- src/snapshot.bin |
使用 snapshot 构建:
1 | zig build -Dsnapshot_path=../../snapshot.bin |
Test:单元、端到端、以及 Web Platform Tests
Unit Tests
1 | make test |
End-to-end tests
要跑端到端测试,需要把 demo repo clone 到 ../demo,并安装 demo 的 node requirements,还需要 Go > 1.24:
1 | make end2end |
Web Platform Tests(WPT)
Lightpanda 也会跑标准化的 Web Platform Tests,并使用一个 fork(含自定义 testharnessreport.js)。
Configure WPT HTTP server
1 | git clone -b fork --depth=1 git@github.com:lightpanda-io/wpt.git |
1 | ./wpt make-hosts-file | sudo tee -a /etc/hosts |
1 | ./wpt manifest |
Run WPT test suite
启动 WPT server:
1 | ./wpt serve |
跑 Lightpanda:
1 | zig build run -- --insecure_disable_tls_host_verification |
然后在 demo 的 clone 里跑 wptrunner:
1 | cd wptrunner && go run . |
或跑某个特定测试:
1 | cd wptrunner && go run . Node-childNodes.html |
还可以用 --summary / --json 控制输出,--concurrency 控制并发。
如果你想跑全套,README 也提醒:会很久;可以用 ReleaseFast 模式让测试更快:
1 | zig build -Doptimize=ReleaseFast run |
Contributing:他欢迎 PR,但希望你先签 CLA
Lightpanda 接受 GitHub PR。
提交 PR 时需要签 CLA(CLA.md)。
结尾:Lightpanda 的性格,就是“为 headless 而生的极简强者”
他不想当“Chrome 的替身”,也不想背着一整套桌面浏览器的重量去跑自动化。
他选择了从零开始,用 Zig 写出一个更轻、更快、启动更迅速的 headless browser,并且用 CDP 让你还能继续用 Puppeteer / Playwright / chromedp 的生态。
如果你正在做 AI 代理、自动化、训练、爬取或测试——你会发现 Lightpanda 更像一只训练有素的��工作犬”:
不需要好看的外表,只要反应快、跑得稳、能把任务干干净净地完成。
[^1]: Playwright support disclaimer: Due to the nature of Playwright, a script that works with the current version of the browser may not function correctly with a future version. Playwright may select different execution paths depending on available Web APIs; if Lightpanda adds a new Web API, Playwright may execute new code paths that rely on features not yet implemented. If you hit an issue, open a GitHub issue and include the last known working version of the script.

