Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

css-paint-polyfill

> 前端框架
Open source

CSS Custom Paint / Paint Worklet polyfill with special browser optimizations.

756 stars0 likes2 views
WebsiteGitHub

About

CSS Custom Paint / Paint Worklet polyfill with special browser optimizations.

CSS Custom Paint / Paint Worklets polyfill

A polyfill that brings Houdini's CSS Custom Paint API and Paint Worklets to all modern browsers (Edge, Firefox, Safari and Chrome).

Performance is particularly good in Firefox and Safari, where this polyfill leverages -webkit-canvas() and -moz-element() for optimized rendering. For other browsers, framerate is governed by Canvas toDataURL() / toBlob() speed.

As of version 3, this polyfill also includes basic implementations of CSS.supports(), CSS.registerProperty() and CSS unit functions (CSS.px() etc), which are injected in browsers without native support.

What are Paint Worklets?

Paint Worklets are JavaScript modules in which you can program custom graphics code. Once registered, they can be applied to elements using CSS:

An example box.js worklet:

javascript
registerPaint('box', class {
  paint(ctx, geom, properties) {
    ctx.fillRect(0, 0, geom.width, geom.height)
  }
})

... registered and applied on a page:

javascript
CSS.paintWorklet.addModule('./box.js')

var el = document.querySelector('h1')
el.style.background = 'paint(box)'

For a more complete example, see the demo.


Installation & Usage

xml

Or with a bundler:

javascript
import 'css-paint-polyfill';

... or with ES Modules on the web:

javascript
import 'https://unpkg.com/css-paint-polyfill';

Contributing

See CONTRIBUTING.md.

To hack on the polyfill locally:

bash
git clone [email protected]:GoogleChromeLabs/css-paint-polyfill.git
cd css-paint-polyfill
npm i
npm start
# open http://localhost:5000

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptcsscss-paint-apihoudinipolyfill

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架