hyperscript
Use when writing, reviewing, or debugging _hyperscript — `_=` / `script=` / `data-script` attributes, `on click` handlers, DOM commands like `toggle`/`put`, `behavior` definitions, or local UI glue around HTMX events. Triggers on: "hyperscript", "_=", "on click", "behavior", "HTMX companion", inline `_=` snippets shown without naming the language, or hyperscript that silently does nothing (parse errors).
- License 许可
- Unlicense
- 最近更新
- 2026-10-28
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- hyperscript
- scope
- hyperscript
- requires
- [ "htmx" ]
- description
- Use when writing, reviewing, or debugging _hyperscript — `_=` / `script=` / `data-script` attributes, `on click` handlers, DOM commands like `toggle`/`put`, `behavior` definitions, or local UI glue around HTMX events. Triggers on: "hyperscript", "_=", "on click", "behavior", "HTMX companion", inline `_=` snippets shown without naming the language, or hyperscript that silently does nothing (parse errors).
- source_basis
- official docs + reference + cookbook + README
- last_verified
- 1775433600000
- target_versions
- _hyperscript 0.9.x (verified against 0.9.14 public docs)
02 资源文件 8
- 参考文档evals/evals.json6.6 KB
- 参考文档evals/trigger-evals.json3.8 KB
- 参考文档references/advanced-and-interop.md6.4 KB
- 参考文档references/core-language.md5.9 KB
- 参考文档references/debugging.md3.4 KB
- 参考文档references/dom-and-commands.md4.9 KB
- 参考文档references/events-and-async.md4.7 KB
- 参考文档references/REFERENCE.md5.4 KB
03 SKILL.md 正文
Hyperscript
Use this skill for _hyperscript implementation, debugging, and code review. Read only the reference file(s) needed for the task.
Quick Start
- Identify the domain of the task (syntax/scope, DOM manipulation, events/async, advanced features/JS interop).
- Open the matching file from
references/. - Implement using hyperscript's natural-language command syntax.
- Validate that the solution stays within hyperscript's sweet spot: localized DOM/event behavior on individual elements.
When NOT to Use Hyperscript
- If the task requires complex client-side state shared across many unrelated elements, use JavaScript.
- If the task is primarily HTMX request/response wiring (
hx-get,hx-swap, etc.), use thehtmxskill. - If the solution would be mostly
js ... endblocks, skip hyperscript and write JavaScript directly. - If the task requires a full SPA router, state management library, or build-step framework, hyperscript is not the tool.
Setup Essentials
CDN install (dependency-free, no build step):
<!-- Pin the latest 0.9.x release; 0.9.14 is the version this skill was verified against -->
<script src="https://unpkg.com/hyperscript.org@0.9.14"></script>
Build/import:
import _hyperscript from 'hyperscript.org';
_hyperscript.browserInit();
Attribute names: _, script, or data-script on elements.
Global features via <script type="text/hyperscript"> tags (behaviors, functions, init blocks). Features in script tags apply to body.
External .\_hs files must load before the hyperscript script tag:
<script type="text/hyperscript" src="/behaviors._hs"></script>
<script src="https://unpkg.com/hyperscript.org@0.9.14"></script>
Processing dynamically inserted DOM: call _hyperscript.processNode(element) on elements inserted via manual JavaScript DOM APIs. HTMX swaps and hyperscript's own put command process inserted fragments automatically.
Critical Rules
-
Use
_hyperscript.processNode()for manually inserted HTML. Newly injected DOM from manual JS APIs (appendChild, innerHTML assignment) must be processed. HTMX swaps and the hyperscriptputcommand handle this automatically. -
Queue semantics matter. Event handlers default to
queue last. Make queue behavior explicit when correctness depends on it:queue last(default): drops intermediate events, keeps only the last pending onequeue all: runs all events sequentially in orderqueue first: queues only the first pending event, drops the restqueue none: drops all events while the handler is activeeveryprefix: runs handlers in parallel with no queuing
-
Attribute storage is string-based. Values stored through
@attrbecome strings. Convert explicitly (e.g.,@data-count as Int) when numeric or structured behavior is needed. -
Math expressions require full parenthesization. Hyperscript does not use normal operator precedence for mixed math.
(x * x) + (y * y)is required;x * x + y * yis a parse error. -
Use JS interop deliberately. Use
callandgetfor JS function calls; reserve inlinejs ... endfor cases where hyperscript genuinely cannot express the logic. If the solution becomes mostlyjs ... end, use JavaScript directly. -
Prefer local behavior, not global sprawl. Hyperscript is strongest for localized DOM/event behavior scoped to individual elements. State shared across many unrelated elements belongs in JavaScript, and HTMX request semantics stay in HTMX — use hyperscript only as local glue around
htmx:*lifecycle events (disabling buttons, toggling classes; see HTMX Companion Guidance). -
Advanced features require separate scripts.
worker,socket, andeventsourceare NOT in the default hyperscript bundle. They require either the "Whole 9 Yards" release or individual script includes (/dist/workers.js,/dist/socket.js,/dist/eventsource.js). Always emit the correct script includes when using these features. -
behaviordefinitions must precedeinstall. Behaviors defined locally (in<script type="text/hyperscript">) must appear before elements that install them. Behaviors loaded from external._hsfiles must load before the hyperscript script tag.
HTMX Companion Guidance
Hyperscript excels at local UI glue around HTMX lifecycle events:
- Disable buttons during requests:
on htmx:beforeRequest add @disabled then on htmx:afterRequest remove @disabled - Toggle loading indicators on HTMX lifecycle events
- Manage local element state in response to
htmx:afterSwap,htmx:beforeSend, etc.
When hyperscript handles htmx:* events, the code should be short and focused on the element's own state. If the logic starts coordinating multiple remote elements or making its own HTTP requests, the task has moved into HTMX territory.
HTMX request/response semantics, hx-* attributes, swap strategies, and extension APIs stay in the htmx skill. Route to it when the question is about request configuration, swap targets, or server response format.
Reference Map
- Syntax, variables, scope, conversions, functions, exceptions:
references/core-language.md - DOM queries, DOM mutation, transitions, measurement:
references/dom-and-commands.md - Event handlers, queueing, filters, async transparency, waits:
references/events-and-async.md fetch, JS interop,behavior,worker,socket,eventsource, extensions:references/advanced-and-interop.md- Parse errors, silent no-ops, debugging tools (
log,beep!, hdb):references/debugging.md - Cross-file index and quick lookup:
references/REFERENCE.md
Task Routing
- Installing or initializing hyperscript -> Setup Essentials above
- Understanding syntax, scope, conversions, functions, or exceptions ->
references/core-language.md - Querying or mutating the DOM ->
references/dom-and-commands.md - Event handlers, queueing, filters, or waits ->
references/events-and-async.md - Hyperscript silently does nothing, parse errors, or inspecting behavior at runtime ->
references/debugging.md fetch, navigation, JS calls, inline JS,behavior,worker, sockets, eventsource, or extending the language ->references/advanced-and-interop.md- HTMX + hyperscript patterns -> HTMX Companion Guidance above
- Unsure where to start ->
references/REFERENCE.md - HTMX attribute semantics, swap strategies, server interaction ->
htmxskill - UI component classes and layout ->
tablerskill - Server-side framework lifecycle ->
djangoorlitestarskill
04 同仓库更多 Skills
wizard
Generate an interactive bash wizard that walks a human through a manual procedure — third-party setup, credential provisioning, a one-off migration — opening URLs, capturing values, confirming each step, and writing .env files and CI secrets (GitHub and Gitea/Forgejo Actions).
restore-test-pyramid
Analyze the project's E2E suite and push every assertion that doesn't need a real browser down to a faster integration or unit test, proving each migration honest before thinning E2E.
ponytail-debt
Harvest SHORTCUT markers from the codebase and report them grouped by file, flagging any missing upgrade paths.
humanify
Repair an inherited or human-blocked ticket for agent implementation, or finish its explicit human-only outcome.
fix-pr
Repair an existing pull request's review findings and target-branch conflicts, verify the result, and update the same open PR.
feature-milestones
Reconstruct a fragmented backlog as finishable feature milestones with explicit delivery boundaries and an approval-gated tracker update.