1. How to use?

  1. if ('paintWorklet' in CSS) {
  2. CSS.paintWorklet.addModule('paint.js');
  3. }
  4. // paint.js
  5. registerPaint('transparent-grid', class {
  6. paint(context, size) {
  7. ...
  8. }
  9. })
  1. .container {
  2. background-image: paint(transparent-grid);
  3. }

Notes: An important caveat is that the Paint API only works over https or on localhost. If you’re developing locally, http-server makes it super easy to view your pages on localhost.