### Install Dependencies and Serve Website Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/README.md Run these commands in your terminal to install project dependencies and start the local development server for the hyperscript.org website. Ensure you have Node.js 15 installed. ```bash npm install ``` ```bash npx eleventy --serve ``` -------------------------------- ### Run Manual Test Server Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/manual/README.md Execute this command to start the Node.js server required for testing WebSockets and EventSource. Ensure the `ws` package is installed (`npm install ws`). ```sh # requires the `ws` package: npm install ws node test/manual/server.js # then open http://localhost:3000/test/manual/connections.html ``` -------------------------------- ### 2 Second Wait Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/commands/fetch/scratch.html A basic example demonstrating a 2-second delay before executing an action. No specific setup is required beyond Hyperscript initialization. ```html ``` -------------------------------- ### Install Namespaced Behavior Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/install.md Demonstrates installing a behavior defined under a namespace. ```hyperscript behavior My.UI.Removable on click remove me end ``` ```html
...
``` -------------------------------- ### Load Example from Dropdown Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/playground.html Handles the change event for the examples dropdown. Loads selected example code into the editor and runs it. ```javascript document.getElementById('examples').addEventListener('change', function () { var val = this.value; if (!val) return; this.value = ''; if (BUILTIN_EXAMPLES[val]) { cm.setValue(BUILTIN_EXAMPLES[val]); run(); return; } // Fet ``` -------------------------------- ### Hello World Example in ///_hyperscript Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/getting-started.md A basic 'Hello World' example demonstrating how to put text into an element on click using ///_hyperscript embedded in an HTML attribute. ```html ``` -------------------------------- ### Install Draggable Behavior Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Use the 'install' feature to apply a predefined behavior, such as 'Draggable', to the current element. ```hyperscript install Draggable ``` -------------------------------- ### Basic transition example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/transition.md A simple example of using the `transition` command to fade out an element and then remove it from the DOM upon clicking. ```html
Fade then remove me
``` -------------------------------- ### Start View Transition Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/_includes/commands_table.md Wraps DOM mutations in a View Transition for animated state changes. Example: `start a view transition using "fade" ... end`. ```hyperscript start a view transition using "fade" ... end ``` -------------------------------- ### Fetch and Load Example Code Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/playground.html Fetches example code from the /playground/ directory and updates the CodeMirror editor. Includes error handling for fetch failures. ```javascript fetch('/playground/' + val) .then(function (r) { return r.text(); }) .then(function (text) { cm.setValue(text); run(); }) .catch(function () { document.getElementById('status').innerHTML = 'Failed to load example'; }); ``` -------------------------------- ### Install Behavior with Named Arguments Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/install.md Installs a 'Removable' behavior that uses a specific button to trigger removal. ```html ``` -------------------------------- ### Install Tool Dependencies Source: https://github.com/bigskysoftware/_hyperscript/blob/master/tools/README.md Installs all necessary dependencies for the hyperscript tools. This command should be run from the `tools/` directory. ```sh just install ``` -------------------------------- ### Install Multiple Behaviors Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/install.md Installs both 'Removable' and 'Draggable' behaviors on a single element. ```html
...
``` -------------------------------- ### Hyperscript Component State Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/src/skills/EFFECTIVE_HYPERSCRIPT.md A basic Hyperscript example demonstrating component state management using element-scoped variables and event handling within an HTML element. ```html
0
``` -------------------------------- ### String Prefix Check Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/expressions/comparison-operator.md The 'starts with' operator checks if a string begins with a specified prefix. This example adds a class if the input starts with 'http'. ```html ``` -------------------------------- ### DOM Reference Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Examples of how to reference DOM elements using IDs, classes, queries, attributes, styles, and relative positioning. ```hyperscript #main-div ``` ```hyperscript .active ``` ```hyperscript ``` -------------------------------- ### Use Custom Hyperscript Command Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/extensions.md Example of using the custom 'foo' command after it has been registered. ```hyperscript def testFoo() set str to "foo" foo str end ``` -------------------------------- ### Test Runner Setup Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/manual/connections.html Initializes test counters and defines helper functions for reporting test results and displaying a summary. ```JavaScript var passCount = 0, failCount = 0; function report(container, name, passed, detail) { var div = document.createElement('div'); div.className = 'test ' + (passed ? 'pass' : 'fail'); div.textContent = (passed ? 'PASS' : 'FAIL') + ': ' + name; if (detail) { var pre = document.createElement('pre'); pre.textContent = detail; div.appendChild(pre); } document.getElementById(container).appendChild(div); if (passed) passCount++; else failCount++; } function showSummary() { document.getElementById('summary').textContent = passCount + ' passed, ' + failCount + ' failed'; } ``` -------------------------------- ### Install ///_hyperscript via NPM Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/getting-started.md Install the ///_hyperscript package using npm. This is the recommended approach for projects using a bundler. ```bash npm install hyperscript.org ``` -------------------------------- ### Basic Click Event Handling Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/on.md A simple example demonstrating how to attach a click event listener to an element. ```html
Click Me!
``` -------------------------------- ### Start a View Transition Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/dom.md Initiate a DOM transition using the 'start a view transition' command, which wraps DOM mutations in the browser's View Transition API. Animation is controlled via CSS. ```hyperscript start a view transition put newContent into #container end ``` ```hyperscript start a view transition using "slide-left" remove .active from .tab add .active to me put content into #panel end ``` -------------------------------- ### Built-in Hyperscript Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/playground.html These examples demonstrate common Hyperscript patterns for interactive web components. They include counters, input handling, and dynamic styling. ```html

Counter

\n\n0 ``` ```html

Reactive Counter

\n
\n \n \n 0\n
``` ```html

Hello

\n\n ``` ```html

Color Cycle

\n\n Press and hold\n\n
Watch me change!
``` -------------------------------- ### hs-include Specifiers Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/conclusion.md Examples demonstrating different specifiers for hs-include to select variables from various scopes. ```html ``` ```html ``` ```html ``` ```html ``` -------------------------------- ### DOM Manipulation Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/llms.txt Provides examples of common DOM manipulation tasks such as adding/removing classes, attributes, styles, showing/hiding elements, and managing dialogs. ```hyperscript add .active to me add @disabled to me add {color: red} to me -- inline styles remove .active from #target remove me -- removes element toggle .active on me toggle between .on and .off take .active from .tabs for me -- move class show me hide me focus #input empty #container open #dialog close #dialog ``` -------------------------------- ### Install a Basic Behavior Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/install.md Attaches a 'Removable' behavior to a div, allowing it to be removed on click. ```html
Click to remove me
``` -------------------------------- ### Hyperscript Async Workflow Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/src/skills/EFFECTIVE_HYPERSCRIPT.md An example of an asynchronous workflow in Hyperscript, handling a button click to fetch data, update a result element, and manage a disabled state. ```html ``` -------------------------------- ### Operator Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Illustrates various operators including math, comparison, logical, existence checks, type conversion, and string manipulation. ```hyperscript x + 1 ``` ```hyperscript y * 2 ``` ```hyperscript z mod 3 ``` ```hyperscript x == "foo" ``` ```hyperscript I match <:active/> ``` ```hyperscript x and y ``` ```hyperscript not z ``` ```hyperscript a or false ``` ```hyperscript no element.children ``` ```hyperscript some <.results/> ``` ```hyperscript "10" as Int ``` ```hyperscript x as Values | JSONString ``` ```hyperscript x:String ``` ```hyperscript x:Int! ``` ```hyperscript "foo" in myArray ``` ```hyperscript url starts with "https" ``` ```hyperscript x is between 1 and 10 ``` ```hyperscript #a precedes #b ``` ```hyperscript x contains "hi" ignoring case ``` -------------------------------- ### Install ///_hyperscript via CDN Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/getting-started.md Include this script tag in your HTML to install ///_hyperscript from a CDN. This is a quick way to add the library to your project without a build process. ```html ``` -------------------------------- ### Property Access Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Demonstrates dot notation, possessive, and 'of' expressions for accessing object properties, as well as array indexing. ```hyperscript event.target ``` ```hyperscript the window's location ``` ```hyperscript the location of window ``` ```hyperscript items[0] ``` ```hyperscript obj['key'] ``` -------------------------------- ### Basic Cookie Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/expressions/cookies.md A simple HTML button demonstrating how to set a cookie using an `on click` event. ```APIDOC ## Basic Cookie Example ### Description This example shows a basic HTML button that sets a cookie named 'hello' to the value 'world' when clicked. ### HTML ```html ``` ``` -------------------------------- ### Load Remote Behaviors Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/behavior.md Demonstrates how to load behaviors from an external file before loading the hyperscript library. Ensure behaviors are defined before installation. ```html ``` -------------------------------- ### Format Pizza Toppings using make and Intl.ListFormat Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/make.md This example shows how to format a list of pizza toppings using `Intl.ListFormat` and the `make` command to create DOM elements for each topping. It iterates through the formatted parts and appends them to a target element. ```hyperscript def formatPizzaToppings(toppings) make an Intl.ListFormat from "en", { type: "conjunction" } called listFmt for part in listFmt.formatToParts(toppings) if the part's type is "element" make a put the part's value into its textContent append it to #toppings else append the part's value to #toppings end end end ``` -------------------------------- ### Open Dialogs, Details, Popovers, or Fullscreen Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/_includes/commands_table.md Opens various UI elements. Examples: `open #my-dialog`, `open fullscreen`. ```hyperscript open #my-dialog ``` ```hyperscript open fullscreen ``` -------------------------------- ### Event-Driven Loop Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/async.md This example shows an event-driven loop that pulses a button until a 'stop' event is received. The loop continues as long as the 'stop' event is not detected at the start of each iteration. The cancel button sends the 'stop' event to terminate the loop. ```html ``` -------------------------------- ### Initialize and Run Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/scratch.html Performs an initial run of the code after a short delay. Useful for setting up the initial state. ```javascript setTimeout(run, 100); ``` -------------------------------- ### Access Selected Text Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Get the currently selected text on the page using the 'selection' magic value. Example: `put selection into #out`. ```hyperscript put selection into #out ``` -------------------------------- ### Add class to closest div relative to parent on click Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/expressions/closest.md This example adds a class to the nearest ancestor `
` element, starting the search from the parent element of the clicked element. ```html
...
``` -------------------------------- ### Set Attribute within a `behavior` using `set` Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/set.md When defining a `behavior`, use `set` to apply an attribute to every element the behavior is installed onto. This example sets the `data-linked-scroll` attribute. ```html ``` -------------------------------- ### Accessing and Setting DOM Attributes with Possessive Expression Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/expressions/possessive.md This example shows how to use the possessive expression to get a DOM element's attribute (`@data-demo`) and set it as the content of another element. Ensure the target element has the desired attribute. ```html
``` -------------------------------- ### Event-driven approach with `on` handlers Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/live.md This example shows a basic event-driven approach using `on` handlers for simple interactions. It is suitable for straightforward cases but can become unwieldy with multiple dependencies. ```html ``` ```html ``` -------------------------------- ### DOM Element References Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/llms.txt Examples of how to reference DOM elements using IDs, classes, attributes, styles, and other selectors. ```hyperscript #myId -- by ID .myClass -- by class -- querySelectorAll @name -- attribute on me *color -- style property ``` -------------------------------- ### Create Intl.ListFormat Instance with make Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/make.md Demonstrates creating a new instance of the JavaScript `Intl.ListFormat` class using the `make` command. The instance is then named using `called` for subsequent use. ```hyperscript make an Intl.ListFormat from "en", { type: "conjunction" } called listFmt ``` -------------------------------- ### Queue All Strategy for Events Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/events.md This example demonstrates the 'queue all' strategy, where all events are queued and processed sequentially, even if they arrive rapidly. It includes a delay to show the queuing effect. ```html -- ``` -------------------------------- ### Hyperscript Init Blocks Source: https://github.com/bigskysoftware/_hyperscript/blob/master/src/skills/EFFECTIVE_HYPERSCRIPT.md Demonstrates `init` blocks for running code when an element is initialized, including immediate execution options. ```hyperscript init add .loaded to me end init immediately -- runs before other features are installed set :count to 0 end ``` -------------------------------- ### Load Initial Content for CodeMirror Editor Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/playground.html Loads initial content into the CodeMirror editor from URL parameters (LZ-compressed) or local storage. Defaults to a 'hello world' example if no source is found. ```javascript var params = new URLSearchParams(window.location.search); var sharedSrc = params.get('src'); var snippet = localStorage.getItem('playground-snippet'); if (sharedSrc) { try { cm.setValue(LZString.decompressFromEncodedURIComponent(sharedSrc)); } catch (e) { cm.setValue(BUILTIN_EXAMPLES.hello); } } else if (snippet) { localStorage.removeItem('playground-snippet'); cm.setValue(snippet); } else { cm.setValue(BUILTIN_EXAMPLES.hello); } ``` -------------------------------- ### Initialize Element with Transitions Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/events.md The `init` block allows you to run commands when an element is first loaded. This example fades in the element over 3 seconds. ```html
Fade Me In
``` -------------------------------- ### Get JavaScript Value with hyperscript Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/_includes/commands_table.md Use `get` to retrieve a value from an expression, like a JavaScript function. ```hyperscript get prompt('Enter your name') ``` -------------------------------- ### Simple Offline Page Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/intercept.md Configures precaching for essential files and an offline fallback page. Uses network-first for all requests, falling back to the offline page if necessary. ```hyperscript intercept / precache /, /offline.html, /style.css as "v1" on * use network-first offline fallback /offline.html end ``` -------------------------------- ### make Command Syntax Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/make.md Provides the EBNF syntax for the `make` command, illustrating its two primary forms: constructing class instances with `from` and creating DOM elements using a query reference. ```ebnf make (a | an) [from ] [called ] make (a | an) [called ] ``` -------------------------------- ### Install 'Removable' Behavior on an Element Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/behavior.md Installs the previously defined 'Removable' behavior onto a div element, making it disappear when clicked. ```html
Click to get rid of me
``` -------------------------------- ### Combined Load, Scroll, and Body Resize Events Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/manual/resize-targets.html This example combines `load`, `scroll from window`, and `resize from body` events. It fires on page load, window scroll, and body resize, demonstrating handling multiple event types and targets. ```hyperscript on load or scroll from window or resize from body log("Load, scroll, or body resize detected!") ``` -------------------------------- ### Hyperscript CLI Validation Error Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/conclusion.md An example of the output from the hyperscript CLI validator, showing a syntax error with file, line, and column information. ```bash src/index.html:14:23 error: Unexpected Token : sett 14 | | ~~~~ ``` -------------------------------- ### Show/hide using opacity strategy Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/dom.md Customize the `show` and `hide` commands to use different CSS properties. This example uses the `opacity` property instead of `display`. ```html ``` -------------------------------- ### Issue a Fetch Request with Hyperscript Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/networking.md Use the `fetch` command to make HTTP requests. This example shows a simple click handler that fetches data and updates an output element. ```html -- ``` -------------------------------- ### Display a prompt and greet the user with ///_hyperscript Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/ask.md Use the `ask` command to prompt the user for input. Check if the input is not null before using it to update the DOM. ```html ``` -------------------------------- ### Install a Behavior onto an Element Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/components.md Install the 'Removable' behavior onto a div with the class 'banner'. The behavior is configured to use an element with the ID 'close-banner' as its 'removeButton' argument. ```html ``` -------------------------------- ### Initialize CodeMirror Editor Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/scratch.html Sets up a CodeMirror editor instance with specific configurations for _hyperscript, including line wrapping, bracket matching, linting, and custom key bindings for running code and showing hints. ```javascript var cm = CodeMirror(function(elt) { elt.parentNode.insertBefore(elt, elt.nextSibling); }, { mode: "htmlmixed", value: DEFAULT_HTML, tabSize: 2, indentWithTabs: true, lineWrapping: true, matchBrackets: true, gutters: ["CodeMirror-lint-markers"], lint: { getAnnotations: lintHyperscript, async: false }, extraKeys: { 'Ctrl-Enter': run, 'Cmd-Enter': run, 'Ctrl-Space': function (cm) { cm.showHint({ hint: hsHint }); }, } }); ``` -------------------------------- ### Function Calls with 'call' and 'get' Commands Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/language.md Illustrates using 'call' for explicit function invocation and 'get' for retrieving values, with 'then' and 'it' for chaining and referencing results. ```hyperscript call alert('hello world!') ``` ```hyperscript get document.getSelection() then log it -- using the 'it' alias for 'result` ``` -------------------------------- ### Initializing EventSource and Handling Messages Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/eventsource.md Set up an EventSource connection and define how to handle incoming messages. This example connects to 'http://server-name/record-updater' and updates specific HTML elements based on received JSON data. ```html

Real-Time Record

Name: ...
Username: ...
Email:
``` -------------------------------- ### Get User Input and Display Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/call.md The `get` command, an alias for `call`, can retrieve user input via `prompt` and then update the element's `innerHTML` with the result stored in `$it`. ```html
Click Me!
``` -------------------------------- ### Two-Way Binding Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md The 'bind' feature synchronizes values between two different elements or properties. This example binds the 'checked' state of an element with the ID 'toggle' to a '.dark' class. ```hyperscript bind .dark and #toggle's checked ``` -------------------------------- ### Install 'Removable' Behavior with a Specific Button Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/behavior.md Installs the 'Removable' behavior on a banner div, specifying a close button using a CSS selector. The behavior will remove the banner when the button is clicked. ```html ``` -------------------------------- ### Install ///_hyperscript as ES Module via CDN Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/getting-started.md Use this script tag to install ///_hyperscript as an ES module from a CDN. This is suitable for projects that use modern JavaScript module systems. ```html ``` -------------------------------- ### Hyperscript Local Variable and Logging Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/language.md This example demonstrates creating a local variable 'x' using 'set', assigning it a value, and then logging that variable to the console using the 'log' command. It requires an HTML button to trigger the script. ```html ``` -------------------------------- ### Filterable Table Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/patterns/lists-forms/filterable-table.md This example shows a complete HTML structure for a filterable table, including input, data rows, and group sections. It is styled with CSS and uses hyperscript for dynamic filtering. ```html

Engineering

Ada LovelaceCompiler Lead
Grace HopperPrincipal Engineer
Linus TorvaldsKernel Maintainer

Design

Dieter RamsIndustrial Designer
Susan KareIcon Designer

Operations

Marie CurieLab Director
Rosalind FranklinImaging Lead
``` -------------------------------- ### Hyperscript Initialization and State Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/patterns/lists-forms/reactive-todo-list.md Demonstrates the initialization of global state variables `$todos` and `$search` using the `init` command. `$todos` is an array of objects, and `$search` is a string bound to an input field. ```hyperscript init set $todos to [{text:'Learn hyperscript', done:true}, {text:'Build something cool', done:false}, {text:'Ship it', done:false}] set $search to '' ``` -------------------------------- ### Evaluate and Store Expression Result with 'get' Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/language.md Use the `get` command to compute an expression and store its result in the `it` variable for subsequent commands. This is useful for chaining operations where the output of one command is the input for another. ```hyperscript get the closest
log it send submit to it ``` -------------------------------- ### Configure EventSource Connection Options Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/eventsource.md Specify connection options like credentials, HTTP method, and custom headers using the 'with' keyword. The value for headers must be an object literal. ```hyperscript eventsource Feed from /api/stream with credentials with method "POST" with headers {"Authorization": "Bearer abc"} on "update" as json log it end end ``` -------------------------------- ### Replace attribute values with `giving` Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/take.md Replaces `aria-selected` attribute values between tab elements. The clicked tab gets `aria-selected="true"`, and others get `aria-selected="false"`. Use for managing ARIA states in tab interfaces. ```html
``` -------------------------------- ### Number Literal Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Use JavaScript-style numbers for numeric values. ```hyperscript 1 ``` ```hyperscript 3.14 ``` -------------------------------- ### Serve Project Locally Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/manual/README.md Use this command to serve the project locally for testing worker scripts that require `importScripts`. Open the specified URL in your browser. ```sh # from the project root npx serve . # then open http://localhost:3000/test/manual/workers.html ``` -------------------------------- ### Boolean Literal Examples Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Use JavaScript-style booleans for true/false values. ```hyperscript true ``` ```hyperscript false ``` -------------------------------- ### Using Fetch as a Stream for SSE Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/features/eventsource.md Utilize the `fetch` command with the `as Stream` conversion for one-shot SSE streams. This is suitable for AI chat responses or progress updates where long-lived connection management is not required. ```hyperscript fetch /api/generate as Stream ``` -------------------------------- ### Date Range Input Binding Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/patterns/lists-forms/dependent-range.md Binds two date inputs so that the start date constrains the end date's minimum and the end date constrains the start date's maximum. The browser's native date picker automatically handles the visual indication of invalid dates. ```html
``` -------------------------------- ### Object Literal Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Use JavaScript-style object literals for key-value pairs. ```hyperscript {foo:"bar", doh:42} ``` -------------------------------- ### Array Literal Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Use JavaScript-style array literals for ordered collections. ```hyperscript [1, 2, 3] ``` -------------------------------- ### Initialize CodeMirror Editor with Hyperscript Mode Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/scratch.html Sets up a CodeMirror editor instance with the 'html-hyperscript' mode and 'nord' theme. Includes default HTML content with Hyperscript examples for demonstration. ```javascript var DEFAULT_HTML = '\n\ \n\

Counter

\n\
\n\ \n\ \n\ \n\
\n'; var cm = CodeMirror.fromTextArea(document.getElementById('editor'), { mode: 'html-hyperscript', theme: 'nord', lineNumbers: true }); ``` -------------------------------- ### Example Tab-Set Component Usage Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/patterns/components/tab-set.md Demonstrates how to use the `` component. Tab buttons must be placed in the 'tab-bar' slot, and their `aria-controls` attribute must match the `id` of the corresponding tab panel. ```html

Everything you'd want from a tab set, and nothing you wouldn't.

``` -------------------------------- ### View Transition Syntax Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/view-transition.md The EBNF syntax for the `start a view transition` command, showing the optional `using` clause for specifying transition types. ```ebnf start [a] view transition [using ] end ``` -------------------------------- ### Hyperscript Cookie Management Source: https://github.com/bigskysoftware/_hyperscript/blob/master/src/skills/EFFECTIVE_HYPERSCRIPT.md Illustrates Hyperscript commands for getting, setting, and clearing cookies. ```hyperscript cookies.name -- get cookie set cookies.name to "value" -- set cookie cookies.clear("name") -- remove cookie cookies.clearAll() -- remove all ``` -------------------------------- ### Open Command Syntax Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/open.md The general syntax for the open command, including optional fullscreen keyword and target expression. ```ebnf open [fullscreen] [] ``` -------------------------------- ### Call Command Syntax Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/call.md Defines the basic syntax for the `call` and `get` commands in ///_hyperscript. ```ebnf call ``` ```ebnf get ``` -------------------------------- ### Navigate to a URL with 'go' Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/getting-around.md Use the 'go' command to navigate the browser to a new URL. This can be an external website or a URL stored in a variable. ```html ``` -------------------------------- ### Initialize Hyperscript Source: https://github.com/bigskysoftware/_hyperscript/blob/master/test/commands/fetch/scratch.html Initializes the Hyperscript library by dynamically importing it. This should be called once at the start of your application. ```javascript (async function () { window._hyperscript = (await import('../../../src/web/_hyperscript_w9y.js')).default })() ``` -------------------------------- ### Scroll to an element Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/scroll.md Use this to scroll an element into view when clicked. No special setup is required. ```html ``` -------------------------------- ### Fetch with Request Options Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/fetch.md Pass request options like method, body, and headers using the 'with' clause. These map to the Fetch API's RequestInit object. ```hyperscript fetch /api/users with method:"POST", body:"name=Joe", headers:{Accept:"application/json"} ``` ```hyperscript fetch /api/users with { method:"POST", body:"name=Joe" } ``` -------------------------------- ### Null Literal Example Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/reference.md Use JavaScript-style null for representing the intentional absence of any object value. ```hyperscript null ``` -------------------------------- ### Fetch Data and Update HTML with hyperscript Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/commands/fetch.md A simple example demonstrating how to fetch data from a URL and directly insert the response into the element's innerHTML. ```html ``` -------------------------------- ### Display Element Size with Resize Events Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/docs/events.md This example uses the `on resize` event to capture the width and height of a div and display it in an output element. The `detail` object provides dimensions. ```html
Resize me
``` -------------------------------- ### Transition Property Source: https://github.com/bigskysoftware/_hyperscript/blob/master/www/_includes/commands_table.md Use to transition CSS properties on an element. Example: `transition my *opacity to 0`. ```hyperscript transition my *opacity to 0 ```