DEV Community

Deniz Akşimşek
Deniz Akşimşek

Posted on • Originally published at denizaksimsek.com on

Sprinkle Sharing

This post is directly from my notes, with no edits.

When people talk about code sharing between server and client, the usual suspects are Node.js and sharing model classes. However, there’s often good reason to duplicate these.

A far more interesting type of code sharing to me is eliminating this duplication:

When you are writing a server-driven web app with “sprinkles” of JS, you want to have interactive components, but also deliver usable HTML to non-JS-enabled [1] clients. This means you are essentially writing a component with the first render and subsequent updates are written in different languages – HTML then JS. How to make this nicer? (Existing answers follow)

Alpine and similar

Write both in one language: “HTML with JS inline in special attributes”.

React and similar

Write both in one language: “JS optionally with JSX”. Hard to set up sprinkle style, but wasn’t this how it was originally created to be used?


  1. “Non-JS-enabled” includes not only browsers where the user turned off JS, but also times when the JS didn’t load, or errored due to use of unsupported modern features. ↩︎

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay