Write, debug, and tune Playwright specs with locator strategy, trace diagnosis, and CI-aware timeouts.
Browser
Web Workers
Try itUse when moving expensive browser work off the main thread with Web Workers, SharedWorker, worker pools, Comlink, transferable objects, Vite/Webpack worker integration, or UI responsiveness fixes. Do not use for lightweight synchronous work or DOM manipulation; Chinese triggers include Web Worker, b
What it does
1. 先确认瓶颈:任务超过约 10ms、用户输入延迟明显、FPS 下滑或大文件解析/图像处理/加密计算才考虑 Worker。 2. 选择通信模型:简单任务用 ,函数式 RPC 用 Comlink,大量并行小任务用 Worker pool,跨 Tab 同步用 SharedWorker。 3. 设计消息协议:请求/响应类型、错误类型、取消或超时策略都要明确。 4. 传大对象时优先 Transferable Objects;不要让结构化克隆吞掉 Worker 带来的收益。 5. 在组件或页面卸载时 ,并通过 Profiler、Performance 面板或 FPS 指标验证主线程改善。
The skill document
Web Workers
Purpose
把昂贵计算移出主线程,保持输入、滚动和动画响应。
Procedure
- 先确认瓶颈:任务超过约 10ms、用户输入延迟明显、FPS 下滑或大文件解析/图像处理/加密计算才考虑 Worker。
- 选择通信模型:简单任务用
postMessage,函数式 RPC 用 Comlink,大量并行小任务用 Worker pool,跨 Tab 同步用 SharedWorker。 - 设计消息协议:请求/响应类型、错误类型、取消或超时策略都要明确。
- 传大对象时优先 Transferable Objects;不要让结构化克隆吞掉 Worker 带来的收益。
- 在组件或页面卸载时
terminate(),并通过 Profiler、Performance 面板或 FPS 指标验证主线程改善。
详细参考
- 需要原生 Worker 文件、构建工具导入、React 生命周期封装和清理示例时,加载 references/basic-worker.md。
- 需要 Transferable Objects、Comlink、Worker pool、SharedWorker、CSP 和 SharedArrayBuffer 注意事项时,加载 references/advanced-workers.md。
Constraints
- Worker 内不能访问 DOM、
window、document、alert()或同步localStorage。 - 高频通信可能比主线程计算更慢;先测量再拆分。
- Worker 文件必须同源加载,并受
worker-srcCSP 限制。 - 大型二进制数据优先 transfer,transfer 后原引用会失效。
- 每个 Worker 有独立 JS 堆,必须主动管理生命周期和内存。
Expected Output
计算密集型操作在后台线程执行,主线程输入和滚动恢复流畅,错误与取消路径明确,Worker 在卸载时被终止且无内存泄漏。
Related skills
Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.
Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.
Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.
Run Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.
Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.
More from bovinphang
Browse all skillsGenerate or edit diagrams, visual assets, and image workflows with reviewable PNG self-checks and bounded self-repair.
Use when creating editable technical diagrams with draw.io / diagrams.net sources, including architecture diagrams, ERD, UML, sequence diagrams, flowcharts, ML model diagrams, official shape lookup, brand symbols, Graphviz auto-layout, codebase structure maps, .drawio validation, or draw.io CLI expo
Use when building, reviewing, or improving frontend UI that needs product-specific design direction, design-system generation, Master/Page overrides, distinctive visual identity, anti-generic interface choices, first-screen hierarchy, UI polish, chart UX, interaction states, responsive behavior, or
Use when creating or reviewing Next.js 14+ App Router projects, file routes, layouts, server/client component boundaries, SSR/SSG/ISR, streaming, metadata, middleware, server actions, or Next-specific data fetching. For generic client React component architecture, apply the project's React conventio
Use when creating, reviewing, or restructuring frontend monorepos with pnpm workspace, Turborepo, Nx, multi-package dependency boundaries, task orchestration, package naming, or package publishing; Chinese triggers include monorepo, workspace, multi-package.
Use when creating or reviewing Nuxt 3 projects, file routes, pages, layouts, SSR/SSG/SPA behavior, Nuxt data fetching, route middleware, plugins, modules, server routes, or Nuxt-specific Vue 3 conventions. For generic Vue component architecture, apply the project's Vue conventions separately; Chines