**Alpha**
| [source code on GitHub](https://github.com/jaandrle/deka-dom-el)
| [*mirrored* on Gitea](https://gitea.jaandrle.cz/jaandrle/deka-dom-el)
| [![git3moji](https://img.shields.io/badge/git3moji%E2%80%93v1-%E2%9A%A1%EF%B8%8F%F0%9F%90%9B%F0%9F%93%BA%F0%9F%91%AE%F0%9F%94%A4-fffad8.svg?style=flat-square)](https://robinpokorny.github.io/git3moji/) <!-- editorconfig-checker-disable-line -->

<p align="center">
	<img src="docs/assets/logo.svg" alt="Deka DOM Elements Logo" width="180" height="180">
</p>

# Deka DOM Elements (dd\<el\> or DDE)

***Vanilla for flavouring โ€” a full-fledged feast for large projects***

*โ€ฆuse simple DOM API by default and library tools and logic when you need them*

```javascript
// ๐ŸŒŸ Reactive component with clear separation of concerns
document.body.append(
	el(EmojiCounter, { initial: "๐Ÿš€" })
);

function EmojiCounter({ initial }) {
	// โœจ State - Define reactive data
	const count = S(0);
	const emoji = S(initial);

	/** @param {HTMLOptionElement} el */
	const isSelected= el=> (el.selected= el.value===initial);

	// ๐Ÿ”„ View - UI updates automatically when signals change
	return el().append(
		el("p", {
			className: "output",
			textContent: S(() =>
				`Hello World ${emoji.get().repeat(count.get())}`),
		}),

		// ๐ŸŽฎ Controls - Update state on events
		el("button", { textContent: "Add Emoji" },
			on("click", () => count.set(count.get() + 1))
		),

		el("select", null, on.defer(el=> el.value= initial),
			on("change", e => emoji.set(e.target.value))
		).append(
			el(Option, "๐ŸŽ‰"),
			el(Option, "๐Ÿš€"),
			el(Option, "๐Ÿ’–"),
		)
	);
}
function Option({ textContent }){
	return el("option", { value: textContent, textContent });
}
```

Creating reactive elements, components, and Web Components using the native
[IDL](https://developer.mozilla.org/en-US/docs/Glossary/IDL)/JavaScript DOM API enhanced with
[**signals/observables**](#understanding-signals).

## Features at a Glance

- โœ… **No build step required** โ€” use directly in browsers or Node.js
- โ˜‘๏ธ **Lightweight** โ€” ~10-15kB minified (original goal 10kB) with **zero**/minimal dependencies
- โœ… **Declarative & functional approach** for clean, maintainable code
- โœ… **Signals and events** for reactive UI
- โœ… **Memoization for performance** โ€” optimize rendering with intelligent caching
- โœ… **Optional build-in signals** with support for custom reactive implementations (#39)
- โœ… **Server-side rendering** support via [jsdom](https://github.com/jsdom/jsdom)
- โœ… **TypeScript support**
- โ˜‘๏ธ **Support for debugging with browser DevTools** without extensions
- โ˜‘๏ธ **Enhanced Web Components** support

## Getting Started

### Documentation

- [**Documentation and Guide**](https://jaandrle.github.io/deka-dom-el)
- [**Examples**](https://jaandrle.github.io/deka-dom-el/p15-examples.html)

### Installation

```bash
npm install deka-dom-el --save
```

โ€ฆor via CDN / Direct Script:

For CDN links and various build formats (ESM/IIFE, with/without signals, minified/unminified), see the [interactive
format selector](https://jaandrle.github.io/deka-dom-el/) on the documentation site.

```html
<!-- Example with IIFE build (creates a global DDE object) -->
<script src="https://cdn.jsdelivr.net/gh/jaandrle/deka-dom-el/dist/iife-with-signals.min.js"></script>
<script>
	const { el, S } = DDE;
	// Your code here
</script>

<!-- Or with ES modules -->
<script type="module">
	import { el, S } from "https://cdn.jsdelivr.net/gh/jaandrle/deka-dom-el/dist/esm-with-signals.min.js";
	// Your code here
</script>
```

## Why Another Library?

This library bridges the gap between minimal solutions like van/hyperscript and more comprehensive frameworks like
[solid-js](https://github.com/solidjs/solid), offering a balanced trade-off between size, complexity, and usability.

Following functional programming principles, dd\<el\> starts with pure JavaScript (DOM API) and gradually adds
auxiliary functions. These range from minor improvements to advanced features for building complete declarative
reactive UI templates.

A key advantage: any internal function (`assign`, `classListDeclarative`, `on`, `dispatchEvent`, `S`, etc.) can be used
independently while also working seamlessly together. This modular approach makes it easier to integrate the library
into existing projects.

## Understanding Signals

Signals are the reactive backbone of Deka DOM Elements:

- [Signals โ€” what's going on behind the scenes](https://itnext.io/signals-whats-going-on-behind-the-scenes-ec858589ea63)
- [The Evolution of Signals in JavaScript](https://dev.to/this-is-learning/the-evolution-of-signals-in-javascript-8ob)
- [TC39 Signals Proposal](https://github.com/tc39/proposal-signals) (future standard)
- [Observer pattern](https://en.wikipedia.org/wiki/Observer_pattern) (underlying concept)

## Contributing

We welcome contributions from the community! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to
get started, coding standards, commit guidelines, and the pull request process.

## Inspiration and Alternatives

- [vanjs-org/van](https://github.com/vanjs-org/van) โ€” World's smallest reactive UI framework
- [adamhaile/S](https://github.com/adamhaile/S) โ€” Simple, clean, fast reactive programming
- [hyperhype/hyperscript](https://github.com/hyperhype/hyperscript) โ€” Create HyperText with JavaScript
- [potch/signals](https://github.com/potch/signals) โ€” A small reactive signals library
- [AseasRoa/paintor](https://github.com/AseasRoa/paintor) - JavaScript library for building reactive client-side user
	interfaces or HTML code.
- [pota](https://pota.quack.uy/) โ€” small and pluggable Reactive Web Renderer. It's compiler-less, includes an html
	function, and a optimized babel preset in case you fancy JSX.
- [jaandrle/dollar_dom_component](https://github.com/jaandrle/dollar_dom_component) โ€”
	Functional DOM components without JSX/virtual DOM
- [TarekRaafat/eleva](https://github.com/TarekRaafat/eleva) โ€” A minimalist, lightweight, pure vanilla JavaScript
	frontend runtime framework.
- [didi/mpx](https://github.com/didi/mpx) โ€” Mpx๏ผŒไธ€ๆฌพๅ…ทๆœ‰ไผ˜็ง€ๅผ€ๅ‘ไฝ“้ชŒๅ’Œๆทฑๅบฆๆ€ง่ƒฝไผ˜ๅŒ–็š„ๅขžๅผบๅž‹่ทจ็ซฏๅฐ็จ‹ๅบๆก†ๆžถ
- [mxjp/rvx](https://github.com/mxjp/rvx) โ€” A signal based frontend framework