Declarative enhancement for HTML: simple, composable, lean. TwinSpark transfers lots of the common logic from JS into a few declarative HTML attributes. This leads to good interactive sites with little JS and more manageable code.

TwinSpark is a battle-tested technology used for years on websites with 100k+ daily active users.

Code example

Explanation: click on an a element (which is enhanced with a ts-req attribute) issues an XHR request to a server. Then replaces the element with response from a server, and calls ts-req-after, which is an action.

<div>
  <a href="/index"
     ts-req
     ts-req-after="target 'sibling div', remove">
     Update me
  </a>
  <div>I'm just hanging out here</div>
</div>
Demo
Update me
I'm just hanging out here

How to use

Just add file to your server’s static folder or use CDN:

<script src="https://cdn.jsdelivr.net/gh/piranha/twinspark-js@main/dist/twinspark.min.js"></script>

What it is

TwinSpark could be mentally split in three parts:

Some reasons why TwinSpark exists despite HTMx and Unpoly (those are similar in approach):

Who is using this

Send pull request or shoot an email to add your site here.

Resources