Zero build step · CDN-first

Declarative HTML Templating
for Vanilla JavaScript

Describe loops, conditions, and state directly in HTML while JavaScript only mutates data. No DOM APIs. No JSX. No build step.

Live Output Running
Count:
index.html — Copy & paste this!
<!-- 1. Include HTTL-S from CDN -->
<script src="https://cdn.jsdelivr.net/gh/KTBsomen/httl-s@main/statejs.js"></script>

<!-- 2. HTML declares how state renders -->
<p>Count: 
  <state-element stateId="counter">
    <template stateId="counter">
      <span>{{clickCount}}</span>
    </template>
  </state-element>
</p>

<button onclick="clickCount++">+ Increment</button>
<button onclick="clickCount = 0">Reset</button>

<!-- 3. JavaScript: watch a variable, re-render on change -->
<script>
  watch('clickCount', (name, value) => {
    setState({ stateId: 'counter', showloader: false });
  }, 0);

  initState();
</script>

How It Works

Three simple concepts — that's the entire mental model.

1

HTML Declares

Use custom elements like <for-loop> and <condition-block> to describe how data should render.

2

JavaScript Mutates

Just change your variables normally. Arrays, objects, primitives — plain JS, nothing special.

3

setState Rebuilds

Call setState() to explicitly trigger DOM updates. No hidden magic, no virtual DOM.

Features

Everything you need for dynamic HTML — nothing you don't.

What HTTL-S Is & Isn't

Honest positioning — no overpromises.

HTTL-S Is

HTTL-S Is Not

When to Use HTTL-S

The right tool for the right job.

Great For

Not Ideal For

Installation

Three steps. Zero config. Start building in under a minute.

Step 1 — Include the script
<script src="https://cdn.jsdelivr.net/gh/KTBsomen/httl-s@main/statejs.js"></script>
Step 2 — Set up watched variables
watch('myVar', (name, value) => {
  setState({ loops: true, conditions: true });
}, initialValue);
Step 3 — Initialize (call LAST!)
initState();

API Reference

The complete API — intentionally small.

Function Description Example

Custom HTML Elements

Declarative building blocks for your templates.

Element Purpose Key Attribute

Interactive Playground

Edit the HTML on the left — see it render live on the right.

editor.html
preview

Click Run to see output.

How It Compares

The honest comparison — use what fits your project.

Feature HTTL-S Alpine.js Vue (CDN) React