The idiomatic way to use the CSS Paint API seems to be:
- Create a 
xyz.jsfile- Populate with a class containing a 
paint(ctx, geom, properties)function - Call 
registerPaint, passing the class as an argument 
 - Populate with a class containing a 
 - Call 
CSS.paintWorklet.addModule('xyz.js')from yourindex.html - Apply the paint worklet in CSS like 
background-image: paint(myPaintWorklet); 
More details on that here: https://developers.google.com/web/updates/2018/01/paintapi
But having to load a separate .js file is a performance hit.
Is there a way to inline the PaintWorklet so that a separate .js file is not needed?
` instead of a file url... Not tried but might work...– Devansh J Apr 03 '19 at 20:47