paint-brush
Exploring Javascript, CSS, and Paint Worklets: Why Put Javascript in Your CSS?by@smpnjn
258 reads

Exploring Javascript, CSS, and Paint Worklets: Why Put Javascript in Your CSS?

by Johnny Simpson9mMarch 11th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Putting CSS in Javascript is pretty much the norm these days - but what if we could do the opposite? Recently, I've been reading quite a bit about Houdini, which gives developers the ability to directly interact with the CSS Object Model. One of the coolest things about it, is that it lets us put Javascript in our CSS. In the example below, I've created a background effect where the Javascript is inside the CSS. Every time you refresh, the background is randomized. Check the CSS tab below to see Javascript inside the CSS. You can even use CSS variables directly in your Javascript code, letting you use standard colors and other settings you configured in your stylesheet.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Exploring Javascript, CSS, and Paint Worklets: Why Put Javascript in Your CSS?
Johnny Simpson HackerNoon profile picture
Johnny Simpson

Johnny Simpson

@smpnjn

Product, Engineering, Web

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Johnny Simpson HackerNoon profile picture
Johnny Simpson@smpnjn
Product, Engineering, Web

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Coffee-web
Linkddl
Leftic
Poast