i:

The i: global attribute marks an element whose content can be fetched from a URL into the editor on demand. Nothing is fetched automatically: you run Input: Fetch [i:] when you want the current content of the URL, and Input: Empty [i:] to clear it again.

Syntax

html
<script i:=//js.rt.ht/retry/.js></script>
<style i:=//example.com/theme.css></style>

Value

URL

Where to fetch the content from: an absolute URL, a protocol-relative URL (//host/path, fetched over https), or a relative URL, which resolves against the editor's own URL. The remote server must allow CORS for https://rtcode.io.

Blank

An element whose value is blank is skipped.

Description

An element with i: stays an ordinary element until you run a command on it. Two commands act on i: elements:

Input: Fetch [i:]

Fills every i: element in the selections, or in the whole input, with the text at its URL. Keys: Ctrl+I, then F / ⌘+I, then F.

Input: Empty [i:]

Empties them. Keys: Ctrl+I, then E / ⌘+I, then E.

A run works like this:

Scope

Each non-empty selection is processed on its own. When every selection is empty, which means only cursors, the whole input is processed.

Elements

Every element whose i: value is not blank. An i: element inside a nested <template> is not reached.

Fetching

The editor fetches each distinct URL once per run, with fetch(), and shares the text between all matching elements and selections. CORS is the only gate.

Failures

Only HTTP status 200 is accepted. Any other status shows a toast with ❌, the status and the URL. A network or CORS failure shows ❌ and the error message. An element whose fetch failed keeps its content.

Filling

Fetch sets the innerHTML of the element to the response text, and Empty sets it to an empty string. Inside <script> and <style> the text is inserted as it is; inside other elements it is parsed as HTML. The i: attribute stays, so the element can be refreshed later.

Usage notes

Select what to process

The command rewrites the text it processes (see below). Select only the elements you want to refresh when the rest of the source should keep its formatting. With only cursors in the editor, the whole input is processed.

The processed text is rewritten

When at least one element was filled or emptied, the whole processed text, which is the selection or the entire input, is replaced by RTCode's serializer output, not by a minimal edit. An undo stop is pushed first. If nothing was filled, the text is left untouched.

CodeLens

Every i:= start tag shows a sticky CodeLens, ↓🌐 <url>, with the tooltip edge-imported. Ctrl+click (⌘+click on macOS) on the lens opens the URL; a plain click jumps to the tag. The lens needs whitespace before i:=.

On deploy

Deploy strips i: from the served HTML and from export bodies, along with the other prefixed attributes. The fetched text stays in the page as authored content. The playground's own output keeps the attribute.

Examples

Vendoring a script

html
<script i:=//js.rt.ht/retry/.js></script>

Put the cursor in the editor and press Ctrl+I, then F / ⌘+I, then F. The editor fetches the URL and writes the code between the tags. Press Ctrl+I, then E / ⌘+I, then E to empty the element again; the attribute stays, so you can fetch again later. When you deploy, i: is stripped and the vendored code stays in the page.

Specifications

Not part of any specification. i: is an RTCode.io editor feature. The fetch follows the Fetch Standard, so the remote server must allow CORS.

It builds on these standards:

Specification
Fetch Standard
MDN: Cross-Origin Resource Sharing (CORS)

Availability

FeaturePlaygroundRTEdge.netNotes
Input: Fetch [i:] and Input: Empty [i:]YesNoEditor commands.
CodeLens ↓🌐 <url>YesNoShown in the editor.
The i: attribute in the pageKeptStrippedDeploy strips it; the fetched text stays inline.
Agent File Sync (Agent Folder Share)YesNoThe attribute is part of the source that 📄.html holds. Chrome or Edge on desktop.

See also