<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Oxford Harrison</title>
    <description>The latest articles on Forem by Oxford Harrison (@oxharris).</description>
    <link>https://forem.com/oxharris</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F360415%2F7a7bfb7c-951b-41ad-8d39-3e4dcd0fdab4.jpg</url>
      <title>Forem: Oxford Harrison</title>
      <link>https://forem.com/oxharris</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/oxharris"/>
    <language>en</language>
    <item>
      <title>A Fresh Take On Reactivity</title>
      <dc:creator>Oxford Harrison</dc:creator>
      <pubDate>Wed, 05 Mar 2025 10:42:10 +0000</pubDate>
      <link>https://forem.com/oxharris/a-fresh-take-on-reactivity-274d</link>
      <guid>https://forem.com/oxharris/a-fresh-take-on-reactivity-274d</guid>
      <description>&lt;p&gt;It's been months of work mocking up a new runtime capability in JavaScript! The new capability lets us have reactivity as an entirely language-driven feature in JavaScript such that using the exact same imperative syntax, we can write programs that automatically reflect changes to state in fine-grained details.&lt;/p&gt;

&lt;p&gt;The idea?:&lt;/p&gt;

&lt;p&gt;Say you have the following piece of logic...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;a change to &lt;code&gt;count&lt;/code&gt;...&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;(being a change in program state) should be automatically reflected down the line such that with the above, the console has a second output of &lt;code&gt;40&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is that thing you want to do in React when you write:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and in a Signals-based framework like Solid when you write:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createSignal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createMemo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;solid-js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createSignal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nf"&gt;createEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;all of which, however, require special metaphors for the job and ultimately result in a new problem: too many moving parts and so much of a Functional Programming exercise for UI development!&lt;/p&gt;

&lt;p&gt;Sit long enough with all current approaches, you realize that there's only so much that's possible without deep language support for reactivity. It comes straight out that the language is its own best enabler of the idea.&lt;/p&gt;

&lt;p&gt;Having itched a ton on this over the past few months, today, I am excited to introduce the underexplored programming paradigm here: Imperative Reactive Programming!&lt;/p&gt;

&lt;p&gt;This is being developed in this &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;little repo&lt;/a&gt; of mine and is ready to be taken for a spin:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/webqit" rel="noopener noreferrer"&gt;
        webqit
      &lt;/a&gt; / &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;
        quantum-js
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A runtime extension to JavaScript that unlocks Imperative Reactive Programming (IRP) in JavaScript!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Quantum JS&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://npmjs.com/package/@webqit/quantum-js" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/593fe8d376e3358f83766671ced3b749fcda737f0b9dc491353fb37d0048ec41/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f407765627169742f7175616e74756d2d6a733f7374796c653d666c617426636f6c6f72413d626c61636b26636f6c6f72423d463044423446" alt="npm version"&gt;&lt;/a&gt;
&lt;a href="https://bundlephobia.com/result?p=@webqit/quantum-js" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/169f75bac9afdbd54fe5c934628aa8b75e9a1918115b84802aa4f57c8e177161/68747470733a2f2f696d672e736869656c64732e696f2f62756e646c6570686f6269612f6d696e7a69702f407765627169742f7175616e74756d2d6a733f7374796c653d666c617426636f6c6f72413d626c61636b26636f6c6f72423d463044423446" alt="bundle"&gt;&lt;/a&gt;
&lt;a href="https://github.com/webqit/quantum-js/blob/master/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/2d0c217db75d22005de49f8dcbcc7e93a02b8d6fb0296e70ec272d46f0ed5863/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7765627169742f7175616e74756d2d6a732e7376673f7374796c653d666c617426636f6c6f72413d626c61636b26636f6c6f72423d463044423446" alt="License"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/webqit/quantum-js#overview" rel="noopener noreferrer"&gt;Overview&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#creating-quantum-programs" rel="noopener noreferrer"&gt;Creating Quantum Programs&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#implementation" rel="noopener noreferrer"&gt;Implementation&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#examples" rel="noopener noreferrer"&gt;Examples&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#license" rel="noopener noreferrer"&gt;License&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Quantum JS is a runtime extension to JavaScript that brings Imperative Reactive Programming to JavaScript!&lt;/p&gt;
&lt;p&gt;What's that?&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Where you normally would require certain reactive primitives to express reactive logic...&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;// Import reactive primitives&lt;/span&gt;
&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-s1"&gt;createSignal&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;createMemo&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;createEffect&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;'solid-js'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-c"&gt;// Declare values&lt;/span&gt;
&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-kos"&gt;[&lt;/span&gt; &lt;span class="pl-s1"&gt;count&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;setCount&lt;/span&gt; &lt;span class="pl-kos"&gt;]&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;createSignal&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-c1"&gt;5&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;doubleCount&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;createMemo&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-s1"&gt;count&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;*&lt;/span&gt; &lt;span class="pl-c1"&gt;2&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-c"&gt;// Log this value live&lt;/span&gt;
&lt;span class="pl-en"&gt;createEffect&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-smi"&gt;console&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;log&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;doubleCount&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;// Setup periodic updates&lt;/span&gt;
&lt;span class="pl-en"&gt;setInterval&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-en"&gt;setCount&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-c1"&gt;10&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c1"&gt;1000&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Quantum JS lets you acheive the same in the ordinary imperative form of the language:&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;// Declare values&lt;/span&gt;
&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-s1"&gt;count&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;5&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Already, you can have much of what you see here working right in your browser via the Quantum JS script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/quantum-js/dist/main.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Details right in the &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;readme&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Laying Reactive Primitives to Rest
&lt;/h2&gt;

&lt;p&gt;Reactivity has only been possible by means of functions. Reactive systems rely on use of these primitives to gain the ability to track state and drive effects.&lt;/p&gt;

&lt;p&gt;By contrast, the language-based model doesn't have this limitation. That effectively renders the essence of these primitives obsolete!&lt;/p&gt;

&lt;p&gt;Coincidentally, this is what would be expected as the natural evolution of reactivity: towards less and less of its mechanical moving parts, not more! (People &lt;em&gt;aren't&lt;/em&gt; itching to have more!)&lt;/p&gt;

&lt;p&gt;It's essentially the path we've been walking for some time now with compilers—Svelte, Vue, React, etc.! (For example, the &lt;a href="https://19.react.dev/learn/react-compiler" rel="noopener noreferrer"&gt;React compiler&lt;/a&gt; now helps you eschew the manual use of &lt;code&gt;useMemo()&lt;/code&gt; and &lt;code&gt;useCallback()&lt;/code&gt;.) Only, we'd know we've hit perfection when there isn't any more primitive to remove!&lt;/p&gt;

&lt;p&gt;There's an old quote regarding this benchmark:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Perfection is attained not when there is nothing more to add, but when there is nothing more to take away."&lt;/em&gt; — Antoine de Saint-Exupéry (1939)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And it turns out, people really want to see things zero down to "arbitrary JS":&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"It’s building a compiler that understands the data flow of arbitrary JS code in components.&lt;/p&gt;

&lt;p&gt;Is that hard? Yeah!&lt;br&gt;
Is it possible? Definitely.&lt;/p&gt;

&lt;p&gt;And then we can use it for so many things…" - &lt;a href="https://twitter.com/sophiebits/status/1628952004725989377" rel="noopener noreferrer"&gt;sophie alpert&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The new language-based model is what you see when you walk the compiler path to its end!&lt;/p&gt;

&lt;h2&gt;
  
  
  Putting the Language to Work in Fun Ways
&lt;/h2&gt;

&lt;p&gt;The first notable thing about the new language-based approach is how you can literally write an arbitrary piece of code... say within a script or function...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Program body:&lt;/span&gt;
  &lt;span class="c1"&gt;// 100s of lines of code here&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;program&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Program body:&lt;/span&gt;
  &lt;span class="c1"&gt;// 100s of lines of code here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and express the &lt;em&gt;additional intent&lt;/em&gt; of reactivity with only a declaration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;shouldbereactive&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Program body:&lt;/span&gt;
  &lt;span class="c1"&gt;// 100s of lines of code here&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;shouldbereactive&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;program&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Program body:&lt;/span&gt;
  &lt;span class="c1"&gt;// 100s of lines of code here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;of course, with &lt;code&gt;shouldbereactive&lt;/code&gt; being actually the keyword &lt;code&gt;quantum&lt;/code&gt;, in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Program body:&lt;/span&gt;
  &lt;span class="c1"&gt;// 100s of lines of code here&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;providing a direct upgrade path from "regular" to "reactive" (and back)—with no changes at all in code.&lt;/p&gt;

&lt;p&gt;Here, the &lt;code&gt;quantum&lt;/code&gt; declaration opts you in to a new execution mode in the runtime—the "quantum" execution mode—in which the runtime stays sensitive to changes in its own state and automatically gets the relevant parts of the program re-executed.&lt;/p&gt;

&lt;p&gt;Being this way a runtime extension (rather than a syntax extension), your involvement in the process is done here. The rest, and bulk, of the story continues within the runtime—and by the "person" that's most specialized in low level things: the runtime itself!&lt;/p&gt;

&lt;p&gt;What's next is the many amazing implications that this has for us as developers!&lt;/p&gt;

&lt;h3&gt;
  
  
  Reactivity in the Full Range of the JS Language
&lt;/h3&gt;

&lt;p&gt;Given a language-level reactive system, think the freedom to use the full range of the JS language without losing reactivity!&lt;/p&gt;

&lt;p&gt;Think &lt;strong&gt;reactive array mutations&lt;/strong&gt;, wherein, given the below...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt; &lt;span class="c1"&gt;// 0, undefined&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;each of the following operations is automatically reflected in the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;T-Shirts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console: 1, 'T-Shirts'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// console: 0, undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think &lt;strong&gt;reactive object mutations&lt;/strong&gt;, wherein, given the below...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined, undefined&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;each of the following operations is automatically reflected in the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Sam&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Sam', undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;assign&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Tam&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Tam', 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ham&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Ham', 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think &lt;strong&gt;live counters&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;with each tick from below automatically reflecting in the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think &lt;strong&gt;&lt;a href="https://github.com/webqit/quantum-js/wiki#with-iterators" rel="noopener noreferrer"&gt;live loops&lt;/a&gt;&lt;/strong&gt;, wherein, given the below...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;products&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;each of the following operations automatically advances the iteration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;T-Shirts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'T-Shirts'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Backpacks&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Backpacks'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think &lt;strong&gt;&lt;a href="https://github.com/webqit/quantum-js/wiki#flow-control" rel="noopener noreferrer"&gt;live flow control constructs&lt;/a&gt;&lt;/strong&gt;, wherein, given the below...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;quantum&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;program&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;condition&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Exiting...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Running...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;program&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Exiting...'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;each of the following operations automatically controls the program flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Running...'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Exiting...'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;condition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// console: 'Running...'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think, think: &lt;a href="https://github.com/webqit/quantum-js/wiki#with-destructuring-assignments" rel="noopener noreferrer"&gt;destructuring assignments&lt;/a&gt;, &lt;a href="https://github.com/webqit/quantum-js/wiki#with-rest-assignments" rel="noopener noreferrer"&gt;rest assignments&lt;/a&gt;, and more.&lt;/p&gt;

&lt;h3&gt;
  
  
  ...and Beyond
&lt;/h3&gt;

&lt;p&gt;Think of some weird things that could now be possible, like &lt;strong&gt;&lt;a href="https://github.com/webqit/quantum-js/wiki#hot-module-system" rel="noopener noreferrer"&gt;"live" module imports&lt;/a&gt; in JavaScript&lt;/strong&gt;! (I.e. Reactivity through the wire!)&lt;/p&gt;

&lt;p&gt;Here's a demo of that that works today:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- exporting module --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt; &lt;span class="na"&gt;quantum&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"module-1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;localVar&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;localVar&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- importing module --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt; &lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;localVar&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#module-1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the ID of the module script above&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;localVar&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1, 2, 3, 4, etc.&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Personally looking forward to how this evolves! For example, might this eventually come to having an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with" rel="noopener noreferrer"&gt;import attribute&lt;/a&gt;?:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;localVar&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#module-1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;live&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Up for a Spin!
&lt;/h2&gt;

&lt;p&gt;It's been super fun building the Quantum JS compiler along with its runtime, and essentially living at the very edge of the JavaScript language—learning every nuance that exists therein! &lt;strong&gt;We're now ready to run in &lt;em&gt;your&lt;/em&gt; browser!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The fastest way to try is via the Quantum JS script loaded from a CDN:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/quantum-js/dist/main.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, of course, that's just one of &lt;a href="https://github.com/webqit/quantum-js#implementation" rel="noopener noreferrer"&gt;many ways&lt;/a&gt;—depending on use case. For example...&lt;/p&gt;

&lt;p&gt;Quantum JS itself has no concept of the DOM, and, as such, no concept of HTML elements like &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;. You'd, instead, need to use the OOHTML implementation of Quantum JS for DOM-based integration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That in place, here are some of my favourite examples which you can copy/paste and run directly in your browser (without a build step):&lt;/p&gt;

&lt;p&gt;
  Example 1: &lt;strong&gt;A Custom Element-Based Counter&lt;/strong&gt;&lt;br&gt;└─────────
  &lt;p&gt;In this example, we demonstrate a custom element that works as a counter. Notice that the magic is in its Quantum &lt;code&gt;render()&lt;/code&gt; method. Reactivity starts at &lt;em&gt;connected&lt;/em&gt; time (on calling the &lt;code&gt;render()&lt;/code&gt; method), and stops at &lt;em&gt;disconnected&lt;/em&gt; time (on calling dispose)! (You can also find this example in the &lt;a href="https://github.com/webqit/quantum-js#examples" rel="noopener noreferrer"&gt;Quantum JS list of examples&lt;/a&gt;.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click-counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Initial rendering&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="c1"&gt;// Static reflection at click time&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;disconnectCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Cleanup&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dispose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;quantum&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;countElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;countElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCountElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#double-count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;doubleCountElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;quadCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;quadCountElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#quad-count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;quadCountElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;quadCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;click-counter&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"display: block; padding: 1rem;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  Click me&lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"count"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"double-count"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"quad-count"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/click-counter&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;
  Example 2: &lt;strong&gt;A Custom &lt;code&gt;URL&lt;/code&gt; API&lt;/strong&gt;&lt;br&gt;└─────────
  &lt;p&gt;In this example, we demonstrate a simple replication of the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/URL" rel="noopener noreferrer"&gt;URL&lt;/a&gt; API - where you have many interdependent properties! Notice that the magic is in its Quantum &lt;code&gt;compute()&lt;/code&gt; method which is called from the constructor. (You can also find this example in the &lt;a href="https://github.com/webqit/quantum-js#examples" rel="noopener noreferrer"&gt;Quantum JS list of examples&lt;/a&gt;.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyURL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="err"&gt;{

    &lt;/span&gt;&lt;span class="nc"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// The raw url&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="c1"&gt;// Initial computations&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;quantum&lt;/span&gt; &lt;span class="nf"&gt;compute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// These will be re-computed from this.href always&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;protocol&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

      &lt;span class="c1"&gt;// These individual property assignments each depend on the previous &lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;//&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// Prevent unnecessary update&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Instantiate&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MyURL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.example.com/path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Change a property&lt;/span&gt;
  &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;protocol&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//Observer.set(url, 'protocol', 'http:');&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// http://www.example.com/path&lt;/span&gt;

  &lt;span class="c1"&gt;// Change another&lt;/span&gt;
  &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hostname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;foo.dev&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;//Observer.set(url, 'hostname', 'foo.dev');&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// http://foo.dev/path&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;
  Example 3: &lt;strong&gt;An Imperative List&lt;/strong&gt;&lt;br&gt;└─────────
  &lt;p&gt;In this example, we demonstrate a reactive list of things. Notice how additions and removals on the &lt;code&gt;items&lt;/code&gt; array are statically reflected on the UI! (You can also find this example and its &lt;em&gt;declarative&lt;/em&gt; equivalent in the &lt;a href="https://github.com/webqit/oohtml#examples" rel="noopener noreferrer"&gt;OOHTML list of examples&lt;/a&gt;.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="c"&gt;&amp;lt;!-- The "items" template --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"partials"&lt;/span&gt; &lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt;  &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;a&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

  &lt;span class="c"&gt;&amp;lt;!-- The list container --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"list"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt; &lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="c1"&gt;// Import item template&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;itemImport&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;partials#item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;itemTemplate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;itemImport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Iterate&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;itemTemplate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cloneNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// Add to DOM&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentItem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="c1"&gt;// Remove from DOM whenever corresponding entry is removed&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;currentItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="c1"&gt;// Render&lt;/span&gt;
      &lt;span class="nx"&gt;currentItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="c1"&gt;// Add a new entry&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Item 4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// Remove an new entry&lt;/span&gt;
    &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  And No, We Aren't Done!
&lt;/h2&gt;

&lt;p&gt;There's definitely a bunch of things to come! And there's definitely a bunch of questions to be answered too, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How does reactivity actually happen? What is the update model?&lt;/li&gt;
&lt;li&gt;How bad, really, was the explicit approach to reactivity?&lt;/li&gt;
&lt;li&gt;What does it look like building real world applications?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This post is the first in a series!&lt;/p&gt;

&lt;h2&gt;
  
  
  Our Star ☆ Button
&lt;/h2&gt;

&lt;p&gt;Would you help our project grow and help more people find us by leaving us a star on github? We, too, have a star button 😅.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/webqit/quantum-js" class="ltag_cta ltag_cta--branded" rel="noopener noreferrer"&gt;Star Us on Github ★&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Much Thanks
&lt;/h2&gt;

&lt;p&gt;...to everyone who gave great feedback on drafts of this post, including: &lt;strong&gt;Joe Pea&lt;/strong&gt;, and &lt;strong&gt;Alex Russell&lt;/strong&gt;!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>reactivity</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Revisiting the HTML Problem Space and Introducing OOHTML</title>
      <dc:creator>Oxford Harrison</dc:creator>
      <pubDate>Wed, 24 Jan 2024 13:01:03 +0000</pubDate>
      <link>https://forem.com/oxharris/revisiting-the-html-problem-space-and-introducing-oohtml-3oh5</link>
      <guid>https://forem.com/oxharris/revisiting-the-html-problem-space-and-introducing-oohtml-3oh5</guid>
      <description>&lt;p&gt;It's 2024! Is it perhaps time to give attention to HTML?&lt;/p&gt;

&lt;p&gt;It's a time when many people are interested in going back to the basics! Even whole teams are looking to make the big return &lt;a href="https://dev.to/oxharris/rethinking-the-modern-web-5cn1#looking-back-the-paradigm-shift"&gt;from rethinking best practices&lt;/a&gt;! (How we, in fact, got fed such a line remains a mystery!)&lt;/p&gt;

&lt;p&gt;But perhaps, no one is talking about the alternative and how still "philosophical" it is to build anything of substance in just HTML, CSS and JS in 2024! In fact, you may contend that &lt;em&gt;a lot&lt;/em&gt; still goes unanswered in our web-native playbooks!&lt;/p&gt;

&lt;p&gt;I'd agree!&lt;/p&gt;

&lt;p&gt;Actually, while it's now possible to streamline your workflow with features like native ES Modules + Import Maps (I can see you on that, &lt;a href="https://twitter.com/trusktr/status/1742622565838066077" rel="noopener noreferrer"&gt;Joe Pea&lt;/a&gt;), the Shadow DOM (I see that you love that, &lt;a href="https://twitter.com/passle_/status/1732659968174694690" rel="noopener noreferrer"&gt;Passle&lt;/a&gt;), CSS nesting, etc., so much is still only philosophical!&lt;/p&gt;

&lt;p&gt;For example, more recently, I decided to play the devil's advocate on the subject myself, and, so, threw in an obvious question: &lt;a href="https://twitter.com/Ox_Harris/status/1741103662104015266" rel="noopener noreferrer"&gt;how do you do reactivity&lt;/a&gt;? (Hoping to hear something intriguing!) But it turns out, we still aren't close! And you're almost always disappointed &lt;a href="https://twitter.com/AgentZeroNine/status/1741140904184844402" rel="noopener noreferrer"&gt;each time&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;It's something we cannot possibly be dogmatic about or evangelize as though there were no limitations when we talk about &lt;a href="https://dev.to/oxharris/rethinking-the-modern-web-5cn1#introducing-webnative-development"&gt;web-native development&lt;/a&gt;. That could make one come across as being out of touch with reality or as being merely dismissive of framework-era innovations!&lt;/p&gt;

&lt;p&gt;Web-native development, from one perspective, simply addresses &lt;em&gt;overheads&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;That's the whole point about "&lt;em&gt;leveraging&lt;/em&gt; native platform capabilities and &lt;em&gt;streamlining&lt;/em&gt; your workflow and tooling budget"! — The web-native manifesto.&lt;/p&gt;

&lt;p&gt;That's the whole point about native technologies like &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components" rel="noopener noreferrer"&gt;Web Components&lt;/a&gt;, speaking of which:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"One of the best outcomes from delegating our component model to the platform is that, when we do, many things get cheaper. Not only can we throw out the code to create and manage separate trees, browsers will increasingly compete on performance for apps structured this way."&lt;/em&gt; — &lt;a href="https://infrequently.org/2017/10/web-components-the-long-game/#:~:text=one%20of%20the%20best%20outcomes%20from%20delegating%20our%20component%20model%20to%20the%20platform%20is%20that%2C%20when%20we%20do%2C%20many%20things%20get%20cheaper.%20not%20only%20can%20we%20throw%20out%20the%20code%20to%20create%20and%20manage%20separate%20trees%2C%20browsers%20will%20increasingly%20compete%20on%20performance%20for%20apps%20structured%20this%20way." rel="noopener noreferrer"&gt;Alex Russel&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;And&lt;/em&gt; should any aspect of that, at some point, begin to go counterproductive, such that you wind up with more boilerplates and homegrown tooling, or more runtime regressions — being oftentimes the counterargument, &lt;strong&gt;it should be time again to &lt;em&gt;address&lt;/em&gt; overheads, not sugar coat them&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;In the spirit of that, here is what I am happy to do today: &lt;strong&gt;discuss specific pain points that have yet to be addressed  natively and touch each one with the relevant part of a proposal you're sure to be excited about: &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;Object-Oriented HTML (OOHTML)&lt;/a&gt;&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;OOHTML is a new set of HTML and DOM-level features designed to make the HTML-First + Progressive Enhancement paradigm a viable idea — initially developed &lt;em&gt;out of need&lt;/em&gt; at WebQit! If you've ever tried, as much as we have, to make success of the above, you probably would come to the same design and architectural conclusions as below and you might as well be inclined to put your money where your mouth is!&lt;/p&gt;

&lt;p&gt;Coincidentally, with vanilla HTML increasingly becoming an attractive option for the modern UI author — amidst a multitude of frameworks, it is a perfect time to revisit the HTML problem space!&lt;/p&gt;

&lt;p&gt;This is a long discussion but I can tell you this will be worth your time and contribution! See what's on the agenda:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Question 1: How Do You Do Reactivity?&lt;/li&gt;
&lt;li&gt;Question 2: How Do You Make Components?&lt;/li&gt;
&lt;li&gt;Question 3: How Do You Re-Use Components?&lt;/li&gt;
&lt;li&gt;Question 4: How Do You Pass Data/Props?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
  &lt;strong&gt;Show Full Outline&lt;/strong&gt;
  &lt;ul&gt;
&lt;li&gt;
Question 1: How Do You Do Reactivity?

&lt;ul&gt;
&lt;li&gt;Introducing: Native Data Binding for HTML&lt;/li&gt;
&lt;li&gt;Wanna Try?&lt;/li&gt;
&lt;li&gt;Introducing: Quantum Reactivity&lt;/li&gt;
&lt;li&gt;This Works Today!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Question 2: How Do You Make Components?

&lt;ul&gt;
&lt;li&gt;Introducing: Namespacing&lt;/li&gt;
&lt;li&gt;Good Thinking?&lt;/li&gt;
&lt;li&gt;Introducing: Style and Script Scoping&lt;/li&gt;
&lt;li&gt;Try Now!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Question 3: How Do You Re-Use Components?

&lt;ul&gt;
&lt;li&gt;
Introducing: HTML Imports

&lt;ul&gt;
&lt;li&gt;Module Definition&lt;/li&gt;
&lt;li&gt;Remote Modules&lt;/li&gt;
&lt;li&gt;Module Imports&lt;/li&gt;
&lt;li&gt;Scoped Modules&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Cool Yet?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Question 4: How Do You Pass Data/Props?

&lt;ul&gt;
&lt;li&gt;Introducing: The Bindings API&lt;/li&gt;
&lt;li&gt;Good Job There?&lt;/li&gt;
&lt;li&gt;Introducing: The Context API&lt;/li&gt;
&lt;li&gt;Exciting Yet?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;



&lt;/p&gt;




&lt;h2&gt;
  
  
  Question 1: How Do You Do Reactivity?
&lt;/h2&gt;

&lt;p&gt;This isn't something Web Components do today! And I do in fact fear that inventing a &lt;em&gt;WC-only&lt;/em&gt; solution to this effect, such that you now have to employ a custom &lt;code&gt;&amp;lt;my-div&amp;gt;&lt;/code&gt; element where a regular &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element would ordinarily suffice, &lt;strong&gt;would yet constitute a new form of &lt;em&gt;overhead&lt;/em&gt;&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;And I'd like to say that what we do in &lt;a href="https://lit.dev/" rel="noopener noreferrer"&gt;Lit&lt;/a&gt; today isn't to me a particularly attractive thing! TL;DR: a &lt;em&gt;runtime&lt;/em&gt; solution to a &lt;em&gt;markup-level&lt;/em&gt; problem is an absolute non-starter! &lt;strong&gt;That's to still miss the essence of a markup language!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You enter a framework like &lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue&lt;/a&gt; or &lt;a href="https://svelte.dev/" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt; and you see something more like the ideal: a markup-based solution — wherein HTML is your first language:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Vue --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: {{ count }}&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Svelte --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: {count}!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Something more HTML-ish now!&lt;/p&gt;

&lt;p&gt;You are able to just write markup and &lt;em&gt;progressively&lt;/em&gt; add logic, as against &lt;em&gt;going ahead of the problem&lt;/em&gt; with a JS-first approach!&lt;/p&gt;

&lt;p&gt;Now, you think of this as a native language feature, and you aren't totally mistaking! For that would be us delegating all of the work to the HTML parser and getting to write code that practically hits the ground running:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Count is: {count}!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Which would mean: no compile step; no waiting for some JS dependency to generate the UI!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: Native Data Binding for HTML
&lt;/h3&gt;

&lt;p&gt;But the Vue/Svelte conventions above aren't where this leads! Not exactly!&lt;/p&gt;

&lt;p&gt;First, we do need a binding syntax that upholds, instead of change, the default behaviour of the opening brace &lt;code&gt;{&lt;/code&gt; and closing brace &lt;code&gt;}&lt;/code&gt; characters in HTML! Whereas these should behave as mere text characters, a new behaviour is introduced above wherein, across the active DOM, every arbitrary text sequence in that form — &lt;code&gt;{count}&lt;/code&gt; — is treated as special and automatically transformed. That as a native language feature (i.e. browsers suddenly waking up with this new rule) would be a breaking change to older code that make up a large percentage of the web today:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  Hello {curly braces}!
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello {curly braces}!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Consider the dilemma: should raw template tags be default-visible so as to be backwards-compatible with older code? Then, newer code would be having a "flash of unrendered content" and an inadvertent exposure of low-level implementation details! Should they be default hidden, then older code would be broken!&lt;/p&gt;

&lt;p&gt;Given how the HTML language currently works, I found a sweet spot with a comment-based approach wherein regular HTML comments get to do the job and double up as dedicated insertion points for application data:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  Hello {curly braces}!

  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: &lt;span class="cp"&gt;&amp;lt;?{count}?&amp;gt;&lt;/span&gt;!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;

  Or, using the comment syntax you might know: &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: &lt;span class="c"&gt;&amp;lt;!--?{count}?--&amp;gt;&lt;/span&gt;!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Count is: &amp;lt;?{count}?&amp;gt;. Hello {curly braces}!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Data-binding expressions are now default-hidden while application data becomes available at any timing! And the idea of having a special behaviour for certain text characters now requires an explicit opt-in using a special opening character sequence &lt;code&gt;&amp;lt;?&lt;/code&gt; (or the longer equivalent &lt;code&gt;&amp;lt;!--?&lt;/code&gt;) and a special closing character sequence &lt;code&gt;?&amp;gt;&lt;/code&gt; (or the longer equivalent &lt;code&gt;?--&amp;gt;&lt;/code&gt;). (Of course, syntax could be improved on where possible!)&lt;/p&gt;

&lt;p&gt;This is something I really do like and I found that it resonates with many developers!&lt;/p&gt;

&lt;p&gt;We next come to attribute bindings and the first challenge becomes whether or not to support text interpolation within attributes as Svelte would have it?:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;&lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"{name} dances."&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Heck! That again would be a breaking change in how curly braces are treated within attributes, just as has been considered above!&lt;/p&gt;

&lt;p&gt;Also, how do you hydrate server-rendered attributes such that, given the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; above, the browser still knows to map the &lt;code&gt;src&lt;/code&gt; and &lt;code&gt;alt&lt;/code&gt; attributes to certain application data after having been rendered to?:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/my/image.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"John Doe dances."&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Interestingly, I did set my foot on this path with OOHTML and that turned out messy!&lt;/p&gt;

&lt;p&gt;Here is where Vue shines with its idea of having a separate, pseudo attribute do the binding for every given attribute:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;v-bind:src=&lt;/span&gt;&lt;span class="s"&gt;"src"&lt;/span&gt; &lt;span class="na"&gt;v-bind:alt=&lt;/span&gt;&lt;span class="s"&gt;"computedExpr"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- Or, for short: &amp;lt;img :src="src" :alt="computedExpr"&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;which renders to:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;v-bind:src=&lt;/span&gt;&lt;span class="s"&gt;"src"&lt;/span&gt; &lt;span class="na"&gt;v-bind:alt=&lt;/span&gt;&lt;span class="s"&gt;"computedExpr"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/my/image.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"John Doe dances."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;thus, obviating the trouble with the former approach. &lt;/p&gt;

&lt;p&gt;But heck! The attribute bloat... the sheer idea of an extra attribute for every given attribute!&lt;/p&gt;

&lt;p&gt;What if we simply had one dedicated attribute for everything wherein we follow a key/value mapping syntax?:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;render=&lt;/span&gt;&lt;span class="s"&gt;"src:src; alt:computedExpr"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- Or, with on-the-fly JS expressions: &amp;lt;img render="src:src; alt:name+' dances.'"&amp;gt; --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;to render to?:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;render=&lt;/span&gt;&lt;span class="s"&gt;"src:src; alt:computedExpr"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/my/image.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"John Doe dances."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That would give us a more compact binding syntax, plus the same benefit as with the Vue approach — of having the original binding logic retained, instead of replaced, after having been rendered!&lt;/p&gt;

&lt;p&gt;We only now need to extend our syntax to support a wider range of DOM element features like "class list" and "style". For this, we introduce the idea of directives, or special symbols, that add the relevant meaning to each binding:&lt;/p&gt;

&lt;p&gt;e.g. the tilde symbol &lt;code&gt;~&lt;/code&gt; for attribute binding:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;render=&lt;/span&gt;&lt;span class="s"&gt;"~src:src; ~alt:computedExpr"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/my/image.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"John Doe dances."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;the percent symbol &lt;code&gt;%&lt;/code&gt; for class binding:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;my-widget&lt;/span&gt; &lt;span class="na"&gt;render=&lt;/span&gt;&lt;span class="s"&gt;"%active:app.isActive"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/my-widget&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;the ampersand &lt;code&gt;&amp;amp;&lt;/code&gt; for CSS binding:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;render=&lt;/span&gt;&lt;span class="s"&gt;"&amp;amp;color:app.themeColor"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;etc.&lt;/p&gt;

&lt;p&gt;I find this very conventional on the backdrop of existing syntaxes like CSS rules! And we've introduced no breaking changes and no funky attribute names!&lt;/p&gt;

&lt;p&gt;But how should bindings be resolved? From an embedded &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag in scope as we have above?:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That idea might be more suited to the Single File Component (SFC) architecture than to the DOM itself where the actual building blocks aren't SFCs but the very DOM nodes themselves!&lt;/p&gt;

&lt;p&gt;Given the DOM, it makes more sense for the said JS references in binding expressions to have to do with the state of those DOM nodes:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;which also resonates with the object/property paradigm of Custom Elements:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;my-counter&amp;gt;&lt;/span&gt;Count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;!&lt;span class="nt"&gt;&amp;lt;/my-counter&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But there goes one subtle challenge: using an element's root namespace for arbitrary state management and potentially conflicting with native methods and properties!&lt;/p&gt;

&lt;p&gt;It turns out, a more decent approach would be to have a dedicated state object for this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And to make this even more flexible, we don't have to restrict the resolution scope of references to the immediate host elements. A more flexible approach would be to have things resolve from &lt;em&gt;the closest node in scope&lt;/em&gt; who exposes said property, such that:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Or, even&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;still works!&lt;/p&gt;

&lt;p&gt;This way, it becomes possible for higher-level state (or even the global state that lives at &lt;code&gt;document.bindings&lt;/code&gt;) to still be reflected at deeply nested elements in the page without having to mechanically pass data from node to mode down the tree!&lt;/p&gt;
&lt;h3&gt;
  
  
  Wanna Try?
&lt;/h3&gt;

&lt;p&gt;Simply include the OOHTML polyfill from a CDN!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;And here's something to try on a blank document:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;

      &lt;span class="c1"&gt;// Global count&lt;/span&gt;
      &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="c1"&gt;// Local count&lt;/span&gt;
      &lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
          &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Global count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;my-counter&amp;gt;&lt;/span&gt;Local count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/my-counter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And you could try writing the "Declarative Lists" example in the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#examples" rel="noopener noreferrer"&gt;list of examples&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;I ask that you share your thoughts and &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟!&lt;/p&gt;

&lt;p&gt;You may want to visit the &lt;a href="https://github.com/webqit/oohtml#data-binding" rel="noopener noreferrer"&gt;Data-Binding section&lt;/a&gt; on the project README to learn more!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: Quantum Reactivity
&lt;/h3&gt;

&lt;p&gt;Data binding isn't all there is to reactivity on the UI!&lt;/p&gt;

&lt;p&gt;While you're able to express JavaScript logic within binding tags:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Global count is: &lt;span class="cp"&gt;&amp;lt;?{ count }?&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Global count, doubled, is: &lt;span class="cp"&gt;&amp;lt;?{ count * 2 }?&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;you still need a way to write &lt;em&gt;reactive&lt;/em&gt; logic in your main application code — i.e. the counter logic itself, above — as things begin to grow and require some form of dependency tracking.&lt;/p&gt;

&lt;p&gt;Here's a sampling across frameworks of how our code could look in a reactive programming paradigm:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Vue --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;computed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: {{ count }}&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Double count is: {{ doubleCount }}&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Svelte --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: {count}!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Double count is: {doubleCount}!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Upcoming Svelte 5 --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;$derived&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Count is: {count}!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Double count is: {doubleCount}!&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But it's a whole new paradigm now from the ordinary &lt;em&gt;imperative&lt;/em&gt; paradigm you started with! Many "reactive primitives" and much symbolism now, and there isn't a universal syntax for this form of programming!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Svelte 3, in 2019, did try to bring reactivity in vanilla JS syntax, as seen in the middle code above, but that was greatly limited &lt;a href="https://svelte.dev/blog/runes" rel="noopener noreferrer"&gt;in many ways&lt;/a&gt;! And, unfortunately, Svelte is unable to move forward with that idea in v5!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Problem with the above is: that whole idea of manually modelling relationships is an overhead; &lt;strong&gt;you're paying a price that need not be paid&lt;/strong&gt;! Short explainer: you do not need to &lt;em&gt;re-express&lt;/em&gt; the dependency graph of your logic &lt;strong&gt;when that's a baseline knowledge for any runtime&lt;/strong&gt;! Plus, you could never do that manually as cheaply, and as accurately as a runtime would!&lt;/p&gt;

&lt;p&gt;Long explainer is what I presented in &lt;a href="https://dev.to/oxharris/re-exploring-reactivity-and-introducing-the-observer-api-and-reflex-functions-4h70"&gt;Re-Exploring Reactivity and Introducing the Observer API and Reflex Functions&lt;/a&gt; — the previous post in this series! You'll find that we can have reactivity without a shift in programming paradigm!&lt;/p&gt;

&lt;p&gt;It turns out, we're able to &lt;em&gt;again&lt;/em&gt; delegate this work to the platform and simply enable reactive programming in the ordinary imperative form of JavaScript! Impossible? That is what we sought to explore with the &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;Quantum JavaScript&lt;/a&gt; project!&lt;/p&gt;

&lt;p&gt;Quantum JS is a runtime extension to JavaScript that lets us write ordinary JavaScript and have it work reactively! Given our markup above, we're able to simply opt-in to reactive programming on the regular &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; element using the &lt;code&gt;quantum&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Global count&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and for the Custom Element definition, we're able to turn our existing &lt;code&gt;connectedCallback()&lt;/code&gt; method to a Quantum function using a special &lt;code&gt;quantum&lt;/code&gt; flag:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Local count&lt;/span&gt;
&lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;quantum&lt;/span&gt; &lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;It's exciting how we practically now have a universal syntax across both reactive and non-reactive code and can now leverage metal-level accuracy and performance! And as a runtime extension to JavaScript, there isn't the "Svelte 3" sort of limitations like relying on symbolism or top-level &lt;code&gt;let&lt;/code&gt; declaration, and others! On the contrary, you are able to enjoy the &lt;a href="https://github.com/webqit/quantum-js/wiki" rel="noopener noreferrer"&gt;full range&lt;/a&gt; of the JS language — conditionals and loops, spread and "rest" syntax sugars, flow control statements, etc.&lt;/p&gt;
&lt;h3&gt;
  
  
  This Works Today!
&lt;/h3&gt;

&lt;p&gt;Simply include the OOHTML Polyfill and you have a new useful magic right in the browser! You wanna try the "Imperative Lists" example in the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#examples" rel="noopener noreferrer"&gt;list of examples&lt;/a&gt; to have a feel!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;You may also want to visit &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;Quantum JS&lt;/a&gt; itself and &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟.&lt;/p&gt;


&lt;h2&gt;
  
  
  Question 2: How Do You Make Components?
&lt;/h2&gt;

&lt;p&gt;Let's say: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components" rel="noopener noreferrer"&gt;Web Components&lt;/a&gt;, or, in other words, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements" rel="noopener noreferrer"&gt;Custom Elements&lt;/a&gt; and the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM" rel="noopener noreferrer"&gt;Shadow DOM&lt;/a&gt; — being collectively a powerful mechanism for encapsulating behaviour, structure, and styling!&lt;/p&gt;

&lt;p&gt;Cool, but... there are times you aren't thinking about a "custom" element or some special technology called Shadow DOM when you say "component"!&lt;/p&gt;

&lt;p&gt;Given the &lt;a href="https://tailwindui.com/components/preview" rel="noopener noreferrer"&gt;tailwind component library&lt;/a&gt; as one random reference&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;a href="https://daisyui.com/components/" rel="noopener noreferrer"&gt;Daisy UI library&lt;/a&gt; as another&lt;/li&gt;
&lt;li&gt;the &lt;a href="https://getbootstrap.com/docs/5.3/examples/#snippets" rel="noopener noreferrer"&gt;Bootstrap starter library&lt;/a&gt; as another&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;a sampling of people's idea of that term should include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a distinct unit of behaviour

&lt;ul&gt;
&lt;li&gt;e.g. a &lt;strong&gt;carousel&lt;/strong&gt; component that enables a certain form of interaction consistently across instances, e.g. rotating through a series of images or content&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;a distinct structural form

&lt;ul&gt;
&lt;li&gt;e.g. a &lt;strong&gt;card&lt;/strong&gt; component that models a certain structure consistently across instances, e.g. featuring an image, a title bar, a description line, a summary area&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;a distinct visual form

&lt;ul&gt;
&lt;li&gt;e.g. a &lt;strong&gt;grid&lt;/strong&gt; component that presents elements in a certain pattern consistently across instances&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that &lt;strong&gt;it isn't always a Web Components' call&lt;/strong&gt;! For example, what have many "visual" components, like &lt;strong&gt;grid&lt;/strong&gt; above, got to do with Custom Elements or Shadow DOM? And let's just say, this whole idea of subtree isolation which the Shadow DOM is best for, isn't always the idea for many, many "components"!&lt;/p&gt;

&lt;p&gt;Consider, for example, structural components, like &lt;strong&gt;card&lt;/strong&gt; above! I often just want a way to "model" the needed relationships, or, in other words, a way to associate the card's features like &lt;em&gt;image&lt;/em&gt; and &lt;em&gt;title bar&lt;/em&gt; with the card, and nothing more! (Something people have done for years with a naming convention like &lt;a href="https://getbem.com/" rel="noopener noreferrer"&gt;BEM&lt;/a&gt;!)&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__image"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"image.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Image"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__title"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Card Title&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Card Description&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__summary"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Card Summary&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;which would translate to writing CSS selectors that feel "namespaced":&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.card__title&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="err"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This means, &lt;strong&gt;you more often just want to write &lt;em&gt;modular markup&lt;/em&gt; and less often want to opt-in to subtree isolation and a new rendering model&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;The ideal authoring experience for HTML, therefore === &lt;strong&gt;having a way to do &lt;em&gt;both&lt;/em&gt; elegantly: author modular markup by default and let the use case decide when to opt-in to the Shadow DOM&lt;/strong&gt;!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: Namespacing
&lt;/h3&gt;

&lt;p&gt;Enter modular markup: we currently have to rely on annoying naming conventions to model relationships. (E.g. BEM, above.) And for the relationships that work with only IDREFs, like the relationship between a &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; and an &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;, and others involving &lt;a href="https://www.w3.org/TR/wai-aria-1.1/#attrs_relationships" rel="noopener noreferrer"&gt;ARIA Relationship Attributes&lt;/a&gt;, we are challenged with HTML's global ID system wherein you have to generate IDs that must be unique throughout the document:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;Home Address&lt;span class="nt"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"home__address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Address&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"home__address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"home__city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;City&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"home__city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;Delivery Address&lt;span class="nt"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"delivery__address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Address&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"delivery__address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"delivery__city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;City&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"delivery__city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This has you thinking globally even when what you're working on has no global relevance! For a fairly-sized document, the level of coordination needed at the global level is often too unrealistic to happen by hand!&lt;/p&gt;

&lt;p&gt;But how about a way to keep those relationships local, or implicitly namespaced? Meet the &lt;code&gt;namespace&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;fieldset&lt;/span&gt; &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;Home Address&lt;span class="nt"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"~address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Address&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"~city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;City&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;fieldset&lt;/span&gt; &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;legend&amp;gt;&lt;/span&gt;Delivery Address&lt;span class="nt"&gt;&amp;lt;/legend&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"~address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Address&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"address-line"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"~city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;City&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"city"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;fieldset&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Notice how we haven't introduced a breaking change to how IDREFs are resolved in browsers! You need the tilde &lt;code&gt;~&lt;/code&gt; character to denote "relativity", or "local" resolution.&lt;/p&gt;

&lt;p&gt;You're able to use that in selectors to match things within a specified namespace:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;fieldset&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="nt"&gt;address-line&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#~address-line&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// null; not in the global namespace&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~address-line&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// null; not in the global namespace&lt;/span&gt;

&lt;span class="nx"&gt;fieldset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#~address-line&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// input#address-line; in the fieldset namespace&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In JavaScript, you are additionally able to access these elements declaratively using the &lt;code&gt;namespace&lt;/code&gt; API:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;city&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fieldset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And you get reactivity for free on top of that — in being able to observe DOM changes happening within given namespace:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Observe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fieldset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;changes&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;changes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Good Thinking?
&lt;/h3&gt;

&lt;p&gt;This is all currently possible using the OOHTML Polyfill!&lt;/p&gt;

&lt;p&gt;The "Multi-Level Namespacing" example in the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#examples" rel="noopener noreferrer"&gt;list of examples&lt;/a&gt; is something you may want to try!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;You may also want to visit the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#namespacing" rel="noopener noreferrer"&gt;Namespacing section&lt;/a&gt; in the project README to learn more!&lt;/p&gt;

&lt;p&gt;I again ask that you share your thoughts and &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: Style and Script Scoping
&lt;/h3&gt;

&lt;p&gt;While namespacing helps us keep IDREFs relative, we still need a way to keep component-specific style sheets and scripts scoped! This &lt;a href="https://vuejs.org/guide/scaling-up/sfc.html" rel="noopener noreferrer"&gt;is a common idea across frameworks&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;Here, we are able to do that using a new &lt;code&gt;scoped&lt;/code&gt; attribute:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nd"&gt;:scope&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// div&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Just like that!&lt;/p&gt;

&lt;p&gt;Now, that comes especially crucial to SPAs!&lt;/p&gt;

&lt;p&gt;It is often asked how the &lt;code&gt;scoped&lt;/code&gt; attribute on the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; element compares with the &lt;code&gt;@scope&lt;/code&gt; rule in the &lt;a href="https://drafts.csswg.org/css-cascade-6/" rel="noopener noreferrer"&gt;CSS Cascading and Inheritance Level 6 Module&lt;/a&gt; which &lt;a href="https://drafts.csswg.org/css-cascade-6/#example-52419898" rel="noopener noreferrer"&gt;lets us do something similar&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;@scope&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;this is red&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;not red&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;But here's the deal with the attribute-based approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Free of an extra nesting level!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Consistent with the syntax for two other things in the scoping agenda: scoped scripts — &lt;code&gt;&amp;lt;script scoped&amp;gt;&lt;/code&gt; — and scoped HTML modules — &lt;code&gt;&amp;lt;template scoped&amp;gt;&lt;/code&gt; — as we'll see shortly!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Presents one way to interpret a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; element: as either "entirely scoped" or "entirely unscoped"; which isn't the case with the &lt;code&gt;@scope&lt;/code&gt; rule approach:&lt;/p&gt;

&lt;p&gt;
  Code
  &lt;br&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/* scoped rules */&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/* unscoped rules */&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;style&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;@scope&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* scoped rules */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* unscoped rules */&lt;/span&gt;
&lt;span class="k"&gt;@scope&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c"&gt;/* scoped rules */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* unscoped rules */&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Notice how the latter requires you to parse the CSS source text itself to know what's going on with a &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; element, vs how the the former removes the guesswork at the attribute level!&lt;/p&gt;
&lt;/blockquote&gt;



&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Presents us an opportunity to have scoped style sheets that can truly make no global footprint, as in, this time, map to their immediate host element instead of to the document:&lt;/p&gt;

&lt;p&gt;
  Code
  &lt;br&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;/* scoped rules */&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;/* unscoped rules */&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Given that the scoped style sheet really has no global relevance&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;styleSheets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;span class="c1"&gt;// Only the second style sheet making a global footprint&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;styleSheets&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That said, here's how the &lt;code&gt;scoped&lt;/code&gt; attribute works for the &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; element:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;:scoped&lt;/code&gt; pseudo selector is treated as a reference the style sheet's host element&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;the relative ID selector, e.g. &lt;code&gt;#~child&lt;/code&gt;, is resolved within given namespace:&lt;/p&gt;

&lt;p&gt;
  Code
  &lt;br&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"child"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"child"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;/* matches only the first "p" */&lt;/span&gt;
  &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="o"&gt;~&lt;/span&gt;&lt;span class="nt"&gt;child&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c"&gt;/* matches all "p" as usual */&lt;/span&gt;
  &lt;span class="nf"&gt;#child&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;whitesmoke&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;where multiple identical scoped styles exists, you are able to add an (experimental) &lt;code&gt;shared&lt;/code&gt; directive, as in &lt;code&gt;&amp;lt;style scoped shared&amp;gt;&lt;/code&gt;, to get only the first instance processed and shared by all host as an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets" rel="noopener noreferrer"&gt;adopted style sheet&lt;/a&gt;, to optimise performance:&lt;/p&gt;

&lt;p&gt;
  Code
  &lt;br&gt;

&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt; &lt;span class="na"&gt;shared&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;style &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt; &lt;span class="na"&gt;shared&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and here's how the &lt;code&gt;scoped&lt;/code&gt; attribute works for the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; element:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;this&lt;/code&gt; keyword is bound to the script's host element&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; element is (re)executed on each re-insertion into the DOM&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Did that just pique your interest?&lt;/p&gt;
&lt;h3&gt;
  
  
  Try Now!
&lt;/h3&gt;

&lt;p&gt;Simply include the OOHTML Polyfill and go ahead with scoping!&lt;/p&gt;

&lt;p&gt;The "Single Page Application" example in the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#examples" rel="noopener noreferrer"&gt;list of examples&lt;/a&gt; is something I'm sure you wanna try!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;You may also want to visit the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#style-and-script-scoping" rel="noopener noreferrer"&gt;Style and Script Scoping section&lt;/a&gt; in the project README!&lt;/p&gt;

&lt;p&gt;And we'd like for you to share your thoughts and &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟!&lt;/p&gt;


&lt;h2&gt;
  
  
  Question 3: How Do You Re-Use Components?
&lt;/h2&gt;

&lt;p&gt;A component architecture is a way to &lt;em&gt;organise code&lt;/em&gt;! That involves being able to work on disparate pieces of an idea and have them automatically come together! It's about the biggest need frameworks fill! Now, something like that in the HTML/DOM land is the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;defs&amp;gt;&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;use&amp;gt;&lt;/code&gt;&lt;/a&gt; system in SVG!&lt;/p&gt;

&lt;p&gt;You could mention the &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; element which affords us a place to define reusable pieces of markup. But the &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; element is really only half the idea of a &lt;em&gt;templating system&lt;/em&gt;; the remaining half left out to imperative DOM APIs:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;fragment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;template&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fragment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cloneNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And when it comes to dealing with remote contents: a different set of APIs:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/file.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This has meant doing half of the work in HTML and half in JS!&lt;/p&gt;

&lt;p&gt;We do have the &lt;a href="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md" rel="noopener noreferrer"&gt;HTML Modules proposal&lt;/a&gt;, &lt;strong&gt;but that's still a JavaScript feature, not HTML&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;But here's what I have always wanted: &lt;strong&gt;a simple define-and-use system in HTML&lt;/strong&gt;, just as with the SVG &lt;code&gt;&amp;lt;defs&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;use&amp;gt;&lt;/code&gt; concept!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: HTML Imports
&lt;/h3&gt;

&lt;p&gt;HTML Imports is a system for &lt;em&gt;templating and reusing objects&lt;/em&gt; - in both &lt;em&gt;declarative&lt;/em&gt; and &lt;em&gt;programmatic&lt;/em&gt; terms! It extends the language with a &lt;em&gt;definition&lt;/em&gt; attribute — &lt;code&gt;def&lt;/code&gt;, complements that with a new &lt;code&gt;&amp;lt;import&amp;gt;&lt;/code&gt; element, and has everything working together as a real-time module system!&lt;/p&gt;

&lt;p&gt;Here, we get a way to &lt;em&gt;both&lt;/em&gt; define and reuse a snippet within same document, exactly as with the SVG &lt;code&gt;&amp;lt;defs&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;use&amp;gt;&lt;/code&gt; system we've always had:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;import&lt;/span&gt; &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/import&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;...while optionally supporting remote content without a change in paradigm:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/foo.html"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;import&lt;/span&gt; &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/import&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Module Definition
&lt;/h4&gt;

&lt;p&gt;You use the &lt;code&gt;def&lt;/code&gt; attribute to expose a &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; element, and optionally, its direct children, as definition:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;A module fragment that can be accessed independently&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Another module fragment that can be accessed independently&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;An element that isn't explicitly exposed.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And you are able to nest modules nicely for code organisation:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"bar"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"nested"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Remote Modules
&lt;/h4&gt;

&lt;p&gt;We shouldn't need a different mechanism to work with remote content.&lt;/p&gt;

&lt;p&gt;Here, OOHTML extends the &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; with an &lt;code&gt;src&lt;/code&gt; attribute that lets us have self-loading &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; elements::&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"bar"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/foo.html"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;└ &lt;em&gt;Loaded file:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;-- file: /foo.html --
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"nested"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/nested.html"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;└ &lt;em&gt;Sub-loaded file:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;-- file: /nested.html --
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And you can lazy-load modules using the &lt;code&gt;loading="lazy"&lt;/code&gt; directive; meaning that loading doesn't happen until the first attempt to access the given model:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/foo.html"&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Module Imports
&lt;/h4&gt;

&lt;p&gt;You use the &lt;code&gt;&amp;lt;import&amp;gt;&lt;/code&gt; element for declarative module imports:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Notice the &lt;em&gt;before&lt;/em&gt; and &lt;em&gt;after&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Before --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;import&lt;/span&gt; &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"/foo"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Default content&lt;span class="nt"&gt;&amp;lt;/import&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- After --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Before --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;import&lt;/span&gt; &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"/foo#fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Default content&lt;span class="nt"&gt;&amp;lt;/import&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- After --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and the HTMLImports API for programmatic module imports:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/foo#fragment1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// module:/foo#fragment1, received synchronously&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;divElement&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/foo#fragment1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;divElement&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;divElement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// module:/foo#fragment1, received synchronously&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/bar/nested#fragment2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;divElement&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;divElement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// module:/bar/nested#fragment2;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Scoped Modules
&lt;/h4&gt;

&lt;p&gt;Just as with scoped styles and scripts above, you are able to scope &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; elements to create an object-scoped module system:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Notice how paths are resolved as to whether globally or relatively.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- module host --&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt; &lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Scoped to host object and not available globally --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;import&lt;/span&gt; &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"foo#fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/import&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Relative path (beginning without a slash), resolves to the local module: foo#fragment1 --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;import&lt;/span&gt; &lt;span class="na"&gt;ref=&lt;/span&gt;&lt;span class="s"&gt;"/foo#fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/import&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Absolute path (beginning with a slash), resolves to the global module: /foo#fragment1 --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Paths are also resolved the same way on the HTMLImports API:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Showing relative path resolution&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;foo#fragment1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;divElement&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;divElement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// the local module: foo#fragment1&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Showing absolute path resolution&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/foo#fragment1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;divElement&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;divElement&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// the global module: foo#fragment1&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;em&gt;Consider:&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Custom elements can now, sometimes, be designed to have their logic decoupled from markup:&lt;/p&gt;


&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;my-element&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- module host --&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;template&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt; &lt;span class="na"&gt;scoped&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Scoped to host object and not available globally --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;def=&lt;/span&gt;&lt;span class="s"&gt;"fragment1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/my-element&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;br&gt;
and in JS:&lt;/p&gt;


&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;customElements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-element&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;HTMLElement&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;divElement&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;foo#fragment1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// the local module: foo#fragment1&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shadowRoot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;divElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cloneNode&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Cool Yet?
&lt;/h3&gt;

&lt;p&gt;This is something you may find really interesting! You'll find that there's a whole lot that a declarative define-and-use system in HTML can change in your daily workflow!&lt;/p&gt;

&lt;p&gt;Simply grab the OOHTML polyfill and game on with some of the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#examples" rel="noopener noreferrer"&gt;examples&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;Once you're comfortable with the basics, you may also want to visit the rest of the story in the &lt;a href="https://github.com/webqit/oohtml?tab=readme-ov-file#html-imports" rel="noopener noreferrer"&gt;HTML Imports section&lt;/a&gt; in the project README!&lt;/p&gt;

&lt;p&gt;And as before, we'd like for you to share your thoughts and &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟!&lt;/p&gt;


&lt;h2&gt;
  
  
  Question 4: How Do You Pass Data/Props?
&lt;/h2&gt;

&lt;p&gt;In a hierarchy of components, parent components often need to pass data down to child components or, in some scenarios, just expose certain data for consumption by anyone, including child components! &lt;/p&gt;

&lt;p&gt;On the first scenario, frameworks that do string concatenation for rendering, e.g. &lt;a href="https://lit.dev" rel="noopener noreferrer"&gt;Lit&lt;/a&gt;, often let you do parent-to-child data-passing via markup/data interpolation, and everything together is parsed into what becomes the DOM:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Example in Lit&lt;/span&gt;
&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="s2"&gt;`
    &amp;lt;h1&amp;gt;Parent Component&amp;lt;/h1&amp;gt;
    &amp;lt;!-- use the dot (.) syntax to pass data as a property --&amp;gt;
    &amp;lt;child-component .data=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;gt;&amp;lt;/child-component&amp;gt;
  `&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;By contrast, data-passing on an already constructed DOM tree is really what we're talking about when it comes to the DOM!&lt;/p&gt;

&lt;p&gt;Interestingly, you could do something as simple as setting arbitrary properties directly on child elements from within a parent element:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Inside a custom element&lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#child&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Only that this isn't very elegant, given that, again, we would be littering an element's root namespace with application data and potentially conflicting with native DOM properties and methods! This is to say, we need a better idea around here!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: The Bindings API
&lt;/h3&gt;

&lt;p&gt;This is a simple, read/write, data object exposed on the document object and on DOM elements as a &lt;code&gt;bindings&lt;/code&gt; property:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Read&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// {}&lt;/span&gt;
&lt;span class="c1"&gt;// Modify&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Demo App&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// { title: 'Demo App' }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Read&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// {}&lt;/span&gt;
&lt;span class="c1"&gt;// Modify&lt;/span&gt;
&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tall-dark&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;normalize&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This is the same Bindings API we introduced in the &lt;a href="https://dev.to/oxharris/html-bmo-temp-slug-6744225?preview=065ed74e3971baef5ddc59438403d900d31f1f6bdbabf03ad1fc884720ab2ebc1e5d27a9bc64481c3354e39109dc7ba94f5fe64c06efd61725d4d68f#introducing-native-data-binding-for-html"&gt;data-binding section&lt;/a&gt;! But it happens to be designed for arbitrary state management - which fits right in with our case:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Notice our use of the Bindings API &lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#child&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And above, if we went further to take advantage of the namespace API, we'd be able to access the said child elements declaratively, as against having to imperatively query the DOM:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Notice our use of the Namespace API &lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;or...&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// We could destructure the above for a more beautiful code&lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;childData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now as a perk, we get reactivity for free on all of the moving parts above: a way to observe when &lt;code&gt;this.bindings.childData&lt;/code&gt; changes and a way to observe when &lt;code&gt;this.namespace.child&lt;/code&gt; changes:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Notice the observers&lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bind&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// bind current values&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;// Bind new values on change&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;childData&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;child&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Better yet, we are able to have that same reactivity happen declaratively if we implemented our &lt;code&gt;connectedCallback()&lt;/code&gt; method as &lt;code&gt;quantum&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Notice the double star&lt;/span&gt;
&lt;span class="nx"&gt;quantum&lt;/span&gt; &lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;childData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And when not dealing with class instances, we are able to achieve the same logic, and same reactivity, using a scoped, &lt;code&gt;quantum&lt;/code&gt; script:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;namespace&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"child"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;scoped&lt;/span&gt; &lt;span class="na"&gt;quantum&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;childData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;  &lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Good Job There?
&lt;/h3&gt;

&lt;p&gt;You'll find that it makes it easier to reason about state management in the DOM, and provides a better way to write Web Components!&lt;/p&gt;

&lt;p&gt;Simply include the OOHTML polyfill from a CDN and game on!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;And here's one take-home idea for a Single Page Application:  the code below, wherein on each navigation to a URL, data is programmatically fetched (via &lt;code&gt;fetch()&lt;/code&gt;), then JSONed to a JavaScript object and held as global state at &lt;code&gt;document.bindings&lt;/code&gt; (which you're able to directly render anywhere in the page):&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
      &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;route&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`http://localhost:3000/api/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt; &lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;pageTitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pageTitle&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hashchange&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Page title is: &lt;span class="cp"&gt;&amp;lt;?{ pageTitle }?&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;(Now, you may fuse that with the "Single Page Application" example in the &lt;a href="https://github.com/webqit/oohtml#examples" rel="noopener noreferrer"&gt;list of examples&lt;/a&gt; to implement individual page layouts for each URL!)&lt;/p&gt;

&lt;p&gt;Maybe you'll have some thoughts to share!&lt;/p&gt;

&lt;p&gt;You may also want to visit the &lt;a href="https://github.com/webqit/oohtml#the-bindings-api" rel="noopener noreferrer"&gt;Bindings API section&lt;/a&gt; on the project README to learn more! And do remember to &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing: The Context API
&lt;/h3&gt;

&lt;p&gt;While we're able to explicitly bind data on DOM nodes using the Bindings API, giving parents a way to pass data down to child components, sometimes the goal is to just expose certain data at a certain level in the DOM tree for consumption by anyone, including child components! This time, instead of the below:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Inside "parent" component&lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;child&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;namespace&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;childData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nx"&gt;child&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;we now want "child" to request said data from "context":&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Inside "child" component&lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;parent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;parentNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;childData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bindings&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;much like an &lt;em&gt;inversion of control&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;Now, while we've used the immediate parent node for our data source above, it is sometimes impossible to predetermine the exact location up the tree to find said data, in which case, the idea of walking up the DOM tree mechanically - &lt;code&gt;this.parentNode.parentNode...&lt;/code&gt; - not only creates a tight coupling between components, but also fails quickly!&lt;/p&gt;

&lt;p&gt;That's where a Context API comes in!&lt;/p&gt;

&lt;p&gt;You'd find the same philosophy with &lt;a href="https://react.dev/reference/react/createContext#usage" rel="noopener noreferrer"&gt;React&lt;/a&gt;, and something similar with &lt;a href="https://lit.dev/docs/data/context/" rel="noopener noreferrer"&gt;Lit&lt;/a&gt;, and perhaps something of same sort with other frameworks!&lt;/p&gt;

&lt;p&gt;In our case, we simply leverage the DOM's existing event system to fire a "request" event and let an arbitrary "provider" in context fulfil the request. All of this is made available via an API named &lt;code&gt;contexts&lt;/code&gt;, exposed on the document object and on DOM elements!&lt;/p&gt;

&lt;p&gt;Here, we get a &lt;code&gt;contexts.request()&lt;/code&gt; method for firing requests:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ------------&lt;/span&gt;
&lt;span class="c1"&gt;// Get an arbitrary&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-element&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ------------&lt;/span&gt;
&lt;span class="c1"&gt;// Prepare and fire request event&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;requestParams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;html-imports&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/foo#fragment1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contexts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requestParams&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ------------&lt;/span&gt;
&lt;span class="c1"&gt;// Handle response&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// It works!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and a &lt;code&gt;contexts.attach()&lt;/code&gt; and &lt;code&gt;contexts.detach()&lt;/code&gt; methods for attaching/detaching providers at arbitrary levels in the DOM tree:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ------------&lt;/span&gt;
&lt;span class="c1"&gt;// Define a CustomContext class&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FakeImportsContext&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;DOMContext&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;kind&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;html-imports&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// '/foo#fragment1'&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;respondWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;It works!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// ------------&lt;/span&gt;
&lt;span class="c1"&gt;// Instantiate and attach to a node&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fakeImportsContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;FakeImportsContext&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contexts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fakeImportsContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ------------&lt;/span&gt;
&lt;span class="c1"&gt;// Detach anytime&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contexts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;detach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fakeImportsContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And everything comes as one standardized API for looking up the document context for any use case! In fact, the Context API is integral to the Namespace API and the Data Binding and HTML Imports features in OOHTML!&lt;/p&gt;

&lt;p&gt;Now, we are able to use the Context API to retrieve the said "binding" in our parent-child scenario earlier:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Inside "child" component&lt;/span&gt;
&lt;span class="nf"&gt;connectedCallback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;requestParams&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;data-binding&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;childData&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;childData&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contexts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;requestParams&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bind&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;childData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Exciting Yet?
&lt;/h3&gt;

&lt;p&gt;This is covered in detail in the &lt;a href="https://github.com/webqit/oohtml#the-context-api" rel="noopener noreferrer"&gt;Context API section&lt;/a&gt; on the project README!&lt;/p&gt;

&lt;p&gt;It goes without saying that this too is possible today using the OOHTML polyfill!&lt;/p&gt;

&lt;p&gt;
  Polyfill
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/@webqit/oohtml/dist/main.lite.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- other code --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;/p&gt;

&lt;p&gt;Take that as an invitation to explore and share your thoughts! And we'll be more than delighted to have you &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;leave us a star&lt;/a&gt; 🌟!&lt;/p&gt;

&lt;p&gt;That's now a wrap!&lt;/p&gt;



&lt;p&gt;But that's probably a lot to unpack! Well, think of OOHTML as not one, but a suite of small, interrelated proposals with one agenda: &lt;strong&gt;towards a more dynamic, object-oriented HTML&lt;/strong&gt;! While features may be discussed or explored individually, the one agenda helps us stay aligned with the original problem!&lt;/p&gt;

&lt;p&gt;As with everything on the web, your contribution is how this gets better!&lt;/p&gt;

&lt;p&gt;The polyfill is actively developed and kept in sync with the spec. You'll find that it goes a long way to help us not think in a vacuum! And it's gone as far as help us build interesting internal apps! (And that's a go ahead to give yours a shot! Not to mean that there aren't bugs there waiting to be discovered!)&lt;/p&gt;

&lt;p&gt;Finally, here we go:&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/webqit" rel="noopener noreferrer"&gt;
        webqit
      &lt;/a&gt; / &lt;a href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;
        oohtml
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Towards a more dynamic and object-oriented HTML.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;OOHTML&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://npmjs.com/package/@webqit/oohtml" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/ab4c5144e9a1ebb00d50ba4eeab42a3adb29861697e59e14ad264d0d9fe20468/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f407765627169742f6f6f68746d6c3f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="npm version"&gt;&lt;/a&gt;
&lt;a href="https://bundlephobia.com/result?p=@webqit/oohtml" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/d091fd159f94e9e36cd97f8da942381e8f83b77d60bf8e07d2a66ba72a9fa55c/68747470733a2f2f696d672e736869656c64732e696f2f62756e646c6570686f6269612f6d696e7a69702f407765627169742f6f6f68746d6c3f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="bundle"&gt;&lt;/a&gt;
&lt;a href="https://github.com/webqit/oohtml/blob/master/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/342007a2f87de48b97d47c8be36114694ada3b7dd7c68503228029f4579ccb33/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7765627169742f6f6f68746d6c2e7376673f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="License"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/webqit/oohtml#explainer" rel="noopener noreferrer"&gt;Explainer&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#features" rel="noopener noreferrer"&gt;Features&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#modular-html" rel="noopener noreferrer"&gt;Modular HTML&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#html-imports" rel="noopener noreferrer"&gt;HTML Imports&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#data-binding" rel="noopener noreferrer"&gt;Data Binding&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#data-plumbing" rel="noopener noreferrer"&gt;Data Plumbing&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#implementation" rel="noopener noreferrer"&gt;Implementation&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#examples" rel="noopener noreferrer"&gt;Examples&lt;/a&gt; • &lt;a href="https://github.com/webqit/oohtml#license" rel="noopener noreferrer"&gt;License&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Object-Oriented HTML (OOHTML) is a set of features that extend standard HTML and the DOM to enable authoring modular, reusable and reactive markup - with a "buildless" and intuitive workflow as design goal! This project revisits the HTML problem space to solve for an object-oriented approach to HTML!&lt;/p&gt;
&lt;p&gt;Building Single Page Applications? OOHTML is a special love letter! Writing Web Components? Now you can do so with zero tooling! Love vanilla HTML but can't go far with that? Well, now you can!&lt;/p&gt;
Versions
&lt;p&gt;&lt;em&gt;This is documentation for &lt;code&gt;OOHTML@4&lt;/code&gt;. (Looking for &lt;a href="https://github.com/webqit/oohtml/tree/v1.10.4" rel="noopener noreferrer"&gt;&lt;code&gt;OOHTML@1&lt;/code&gt;&lt;/a&gt;?)&lt;/em&gt;&lt;/p&gt;

&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Status&lt;/h2&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Actively maintained&lt;/li&gt;
&lt;li&gt;A working implementation&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/WICG/proposals/issues/137" rel="noopener noreferrer"&gt;Proposed at the WICG&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Open to contributions&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Implementation&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;OOHTML may be used today. This implementation adheres closely to the spec and helps evolve the proposal through a practice-driven process.&lt;/p&gt;…&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/webqit/oohtml" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>html</category>
      <category>webqit</category>
    </item>
    <item>
      <title>Re-Exploring Reactivity and Introducing the Observer API and Reflex Functions</title>
      <dc:creator>Oxford Harrison</dc:creator>
      <pubDate>Sat, 01 Jul 2023 04:57:16 +0000</pubDate>
      <link>https://forem.com/oxharris/re-exploring-reactivity-and-introducing-the-observer-api-and-reflex-functions-4h70</link>
      <guid>https://forem.com/oxharris/re-exploring-reactivity-and-introducing-the-observer-api-and-reflex-functions-4h70</guid>
      <description>&lt;p&gt;In the last few years, I have spent an insane amount of time thinking through &lt;em&gt;reactivity&lt;/em&gt; on the frontend! In all that we've achieved in the space, the State of Reactivity today still leaves much to be desired:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;reactive primitives&lt;/strong&gt; - in the various mechanisms for intercepting and reflecting change, there is still &lt;strong&gt;no easy way&lt;/strong&gt; around the concept of change detection! From language-level primitives - proxies and accessors - to custom primitives, this has continued to be a tricky game!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;syntax and mental model&lt;/strong&gt; - in the overall language and programming paradigm around the idea, there's still &lt;strong&gt;no &lt;em&gt;ergonomic&lt;/em&gt; and &lt;em&gt;mentally efficient&lt;/em&gt; way&lt;/strong&gt; to express reactive logic! (Much rigor here often as we try to model normal logic using functions; or try to wield a compiler!)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These challenges greatly impact our work, sometimes in less obvious ways, &lt;strong&gt;given how much of the frontend &lt;em&gt;paradigm&lt;/em&gt; space this useful magic now occupies&lt;/strong&gt;, and thus, how much of it accounts for the code we write and &lt;a href="https://dev.to/oxharris/rethinking-the-modern-web-5cn1"&gt;our overall tooling budget&lt;/a&gt;! For a paradigm so intrinsic to frontend, it couldn't be more compelling to revisit the various painpoints!&lt;/p&gt;

&lt;p&gt;To this end, I took a stab:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;at re-exploring the fundamental idea of change detection in JavaScript (i.e. reactive primitives) and the overall language and programming paradigm around reactivity (i.e. syntax and mental model) for some "cleaner" magic!&lt;/li&gt;
&lt;li&gt;at re-exploring full language support for all of it in each case, given how the idea seems to suffer from meager language support and thus, remains, for the most part, externalized to tooling!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a pretty long article - with 3 main sections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
Re-Exploring Change Detection (The design discussion around the &lt;a href="https://github.com/webqit/observer" rel="noopener noreferrer"&gt;Observer&lt;/a&gt; API)&lt;/li&gt;
&lt;li&gt;
Re-Exploring the Language of Reactivity (The design discussion around &lt;a href="https://github.com/webqit/reflex-functions" rel="noopener noreferrer"&gt;Reflex Functions&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;The Duo and the Prospect for Reactivity&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
  &lt;strong&gt;Show Full Outline&lt;/strong&gt;
  &lt;ul&gt;
&lt;li&gt;
Re-Exploring Change Detection

&lt;ul&gt;
&lt;li&gt;
Accessors and Proxies; the Tricky Parts

&lt;ul&gt;
&lt;li&gt;Accessors Got a Flexibility Problem There&lt;/li&gt;
&lt;li&gt;Proxies Got an Identity Problem There&lt;/li&gt;
&lt;li&gt;The Whole Idea of Internal Traps&lt;/li&gt;
&lt;li&gt;The Whole Idea of "Magic Objects"&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;A Way to Think About the Problem&lt;/li&gt;
&lt;li&gt;Rediscovering Prior Art and Nailing the Problem&lt;/li&gt;
&lt;li&gt;
Introducing the Observer API

&lt;ul&gt;
&lt;li&gt;An Overview&lt;/li&gt;
&lt;li&gt;Featuring Path Observability&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;The Project&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
Re-Exploring the Language of Reactivity

&lt;ul&gt;
&lt;li&gt;
The Toll On Syntax and Mental Model

&lt;ul&gt;
&lt;li&gt;Solving for Syntax&lt;/li&gt;
&lt;li&gt;Solving for Mental Model&lt;/li&gt;
&lt;li&gt;Solving for Both&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Bringing Reactivity to Imperative JavaScript and Nailing the Problem&lt;/li&gt;
&lt;li&gt;
Introducing Reflex Functions

&lt;ul&gt;
&lt;li&gt;An Overview&lt;/li&gt;
&lt;li&gt;Change Propagation&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;The Project&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The Duo and the Prospect for Reactivity&lt;/li&gt;
&lt;li&gt;Acknowledgements&lt;/li&gt;
&lt;li&gt;References&lt;/li&gt;
&lt;/ul&gt;



&lt;/p&gt;




&lt;h2&gt;
  
  
  Update Jan, '24
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/oxharris/re-exploring-reactivity-and-introducing-the-observer-api-and-reflex-functions-4h70#introducing-reflex-functions"&gt;Reflex Functions&lt;/a&gt; has had a major update since this initial announcement! This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A name change: being now &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;Quantum JS&lt;/a&gt;!&lt;/li&gt;
&lt;li&gt;A major API revamp: majorly in the return values of Quantum Functions - from being a tuple &lt;code&gt;[ value, reflect ] = sum()&lt;/code&gt; to being a "State" object &lt;code&gt;state = sum()&lt;/code&gt;!&lt;/li&gt;
&lt;li&gt;An entire compiler overhaul towards a more runtime-driven form of reactivity!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Generally, while the ideas shared here under the term "Reflex Functions" are largely the same with its &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;Quantum JS&lt;/a&gt; successor, there are important differences in the implementation!&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;SECTION 1/3&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Re-Exploring Change Detection
&lt;/h2&gt;

&lt;p&gt;Change detection comes as the first challenge to reactivity in JavaScript!&lt;/p&gt;

&lt;p&gt;The general idea deals with detecting and responding to changes made to JavaScript objects to drive synchronization - sometimes data binding, but generally, any functionality that is dependent on object state. This in JavaScript has been approached in many different ways past and present.&lt;/p&gt;

&lt;p&gt;This wouldn't be about Signals and Hooks, because - &lt;strong&gt;paradigm mismatch&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Those "functional" primitives are designed with the &lt;a href="https://en.wikipedia.org/wiki/Functional_programming" rel="noopener noreferrer"&gt;Functional Programming&lt;/a&gt; paradigm in mind, where immutable data and pure functions are emphasized. Object observability, on the other hand, is more closely associated with the &lt;a href="https://en.wikipedia.org/wiki/Object-oriented_computer_programming" rel="noopener noreferrer"&gt;Object-Oriented&lt;/a&gt; paradigm, where mutable state and object interactions are the idea. And whereas the former basically represents an intermediary event system, the latter deals with object-level change detection via native mechanisms.&lt;/p&gt;

&lt;p&gt;Meanwhile, later in the second half of this article, we will be touching on Signals and Hooks.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;
  Compare also: &lt;strong&gt;Mutability vs. Immutability&lt;/strong&gt;
  &lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Immutable_object" rel="noopener noreferrer"&gt;Immutability&lt;/a&gt; is a programming principle that treats data as unchangeable. Here, the idea of change is modelled by functions that repesent a pipeline of transformations for &lt;em&gt;whole data&lt;/em&gt; wherein each transformation creates a new instance, and observability happens at the event level, well, instead of at the fine-grained level. Mutability, on the other hand, embraces the concept of change, wherein objects are modified in place.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;/p&gt;

&lt;p&gt;Historically, certain techniques have had their day here! For example, &lt;a href="https://docs.angularjs.org/guide/scope#scope-life-cycle" rel="noopener noreferrer"&gt;dirty-checking&lt;/a&gt; was the technique in Angular; and custom &lt;a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern" rel="noopener noreferrer"&gt;pub/sub&lt;/a&gt; mechanisms were the idea in &lt;a href="https://backbonejs.org/#Model-View-separation" rel="noopener noreferrer"&gt;Backbone Models&lt;/a&gt; and &lt;a href="https://guides.emberjs.com/v2.11.0/models/defining-models/" rel="noopener noreferrer"&gt;Ember Models&lt;/a&gt;. These and probably other approaches at the time have now falling out of favour for newer, more straightforward solutions!&lt;/p&gt;

&lt;h3&gt;
  
  
  Accessors and Proxies; the Tricky Parts
&lt;/h3&gt;

&lt;p&gt;Today, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty" rel="noopener noreferrer"&gt;object accessors&lt;/a&gt; (since ES5) and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="noopener noreferrer"&gt;proxies&lt;/a&gt; (since ES6) have greatly revolutionized the problem space! Being integral to the language, these primitives constitute the only way to detect change at the program level:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Accessors&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// name accessors&lt;/span&gt;
  &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// age accessors&lt;/span&gt;
  &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nf"&gt;age&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Proxies&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Original object&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;$person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;age&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;// Proxy wrapper&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Such that we're able to hide &lt;em&gt;a ton&lt;/em&gt; behind a dot syntax:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;James&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Giving a clean interface where you'd normally have needed intermediary &lt;code&gt;get()&lt;/code&gt;/&lt;code&gt;set()&lt;/code&gt; mechanisms is perhaps what makes these so nifty that you definitely want to use them! But then comes additional details to walk through, where you end up with an unexpected amount of boilerplate and a tricky implementation!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's add here that there's something on the horizon: &lt;a href="https://github.com/tc39/proposal-decorators" rel="noopener noreferrer"&gt;Decorators&lt;/a&gt;! (On which Dr. Axel Rauschmayer takes a &lt;a href="https://2ality.com/2022/10/javascript-decorators.html" rel="noopener noreferrer"&gt;deep dive&lt;/a&gt; in their latest, stage 3, syntax.) But it turns out, while decorators might be solving something in the broader scope of meta programming in JavaScript, &lt;strong&gt;they aren't adding anything to &lt;em&gt;change detection&lt;/em&gt; other than syntax sugars over existing possibilities&lt;/strong&gt;! So, if the question is object observabilty, I'm the least excited about decorators!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Accessors Got a Flexibility Problem There
&lt;/h4&gt;

&lt;p&gt;It's probably the biggest deterrent to using them: &lt;strong&gt;the inflexibility of working per-property and not supporting on-the-fly properties&lt;/strong&gt;! This requires you to make upfront design decisions around all the possible ways an object could change at runtime - an assumption that's too unrealistic for many dynamic applications; one that fails quickly if you tried!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Accessors were the primary reactive mechanism in &lt;a href="https://v2.vuejs.org/v2/guide/reactivity.html" rel="noopener noreferrer"&gt;Vue 2&lt;/a&gt;, and that's probably the best place to see their reallife limitations - the biggest of which is perhaps their inability to detect new property additions! This became a big enough issue for the framework that &lt;a href="https://increment.com/frontend/making-vue-3/#:~:text=switching%20to%20proxy%20would%20allow%20us%20to%20eliminate%20vue%E2%80%99s%20existing%20limitations%2C%20such%20as%20the%20inability%20to%20detect%20new%20property%20additions%2C%20and%20provide%20better%20performance." rel="noopener noreferrer"&gt;they didn't hesitate to move away&lt;/a&gt; when they had the chance to!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Proxies Got an Identity Problem There
&lt;/h4&gt;

&lt;p&gt;It turns out that for every "proxy" instance, you practically have to account for two different object identities, &lt;strong&gt;and that comes very problematic for code that relies on type checks (&lt;code&gt;x instanceof y&lt;/code&gt;) and equality checks (&lt;code&gt;x === y&lt;/code&gt;)&lt;/strong&gt;. Heck, even two proxy instances with the same object wouldn't equate, due to their different identities!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As &lt;a href="https://twitter.com/DavidBruant" rel="noopener noreferrer"&gt;David Bruant&lt;/a&gt; would have me do here, let's add that with some hack, you could get "instanceof" working correctly: &lt;a href="https://jsfiddle.net/Lr82xzpm/" rel="noopener noreferrer"&gt;via the &lt;code&gt;getPrototypeOf&lt;/code&gt; trap&lt;/a&gt;. (But I guess that doesn't make the whole idea any less tricky but more!)&lt;/p&gt;

&lt;p&gt;And maybe let's reference &lt;a href="https://twitter.com/tvcutsem" rel="noopener noreferrer"&gt;Tom van Cutsem&lt;/a&gt; on &lt;a href="https://tvcutsem.github.io/js-membranes" rel="noopener noreferrer"&gt;the concept of membranes&lt;/a&gt; and &lt;a href="https://github.com/salesforce/observable-membrane" rel="noopener noreferrer"&gt;Salesforce's implementation of the idea&lt;/a&gt; - wherein you're able to have all references to the same target return the same proxy instance, and thus have references pass "equality checks"! (But I guess membranes aren't what you're really out here to do!)&lt;/p&gt;

&lt;p&gt;All of this is probably another way to see the problem &lt;em&gt;for reactivity&lt;/em&gt; with proxies: &lt;em&gt;tricky&lt;/em&gt;, &lt;em&gt;no easy way out&lt;/em&gt;!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  The Whole Idea of Internal Traps
&lt;/h4&gt;

&lt;p&gt;It comes as a &lt;em&gt;gap&lt;/em&gt; between the communication model that those internal methods enable and the typical model around reactivity: these primitives don't bring with them the regular subscription model wherein anyone can subscribe to changes on a subject! They just give you a way to &lt;em&gt;intercept&lt;/em&gt; - in terms of &lt;em&gt;internal traps&lt;/em&gt; - but not a way to &lt;em&gt;observe&lt;/em&gt; from the outside - in something like a &lt;code&gt;.subscribe()&lt;/code&gt; method! And in however you go from here, this becomes a tricky game all the way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tricky if you were to take those internal methods for generic "observers"!&lt;/strong&gt; In the case of accessors, you couldn't have another "observer" without re-defining a property, and thus &lt;strong&gt;inadvertently displacing an existing one&lt;/strong&gt;! And in the case of proxies, while you wouldn't be able to displace traps anyway as those are finalized at instance time (i.e. closed-in by the constructor), you also couldn't have another "observer" without, this time, creating &lt;em&gt;another proxy instance&lt;/em&gt; over same object, and thus &lt;strong&gt;inadvertently ending up with multiple redundant proxies that are each tracking very different interactions&lt;/strong&gt; - giving you a leaky, bypassable tracking mechanism each time!&lt;br&gt;
 &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Accessors&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* observer 1 */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// Singleton Error: A new observer inadvertently breaks the one before&lt;/span&gt;
&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;age&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* observer 2 */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Proxies&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;$person1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* observer 1 */&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nf"&gt;goEast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$person1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// Singleton Error: A new observer inadvertently creates redundancy&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;$person2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* observer 2 */&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nf"&gt;goWest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$person2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Turns out, those internal methods &lt;em&gt;don't at all add up&lt;/em&gt; to a reactive &lt;em&gt;system&lt;/em&gt;! Until you actually build one, you don't have one!&lt;br&gt;
 &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tricky in going from those internal methods to a "reactive system"!&lt;/strong&gt; You'd need to build an event dispatching mechanism that those internal methods get to talk to, and that couldn't happen without having to walk through new technical details! And there lies many pitfalls! For example, it's quick and easy to inadvertently introduce a breaking change to public object interfaces - e.g. &lt;code&gt;window.document&lt;/code&gt; - by &lt;em&gt;polluting/patching&lt;/em&gt; their namespace with setters and getters, or with something like a &lt;code&gt;.subscribe()&lt;/code&gt; method!&lt;br&gt;
 &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Accessors&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;defineProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;custom&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* observer 1 */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Namespace pollution&lt;/span&gt;
  &lt;span class="na"&gt;_callbacks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
  &lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;_callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// Accessors&lt;/span&gt;
  &lt;span class="kd"&gt;get&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="kd"&gt;set&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Proxies&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;_callbacks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;_callbacks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;$person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Proxy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Namespace pollution&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;subscribe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;subscribe&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Turns out, there's no &lt;em&gt;direct/neat&lt;/em&gt; path to go from "internal methods" to "reactive system"! &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  The Whole Idea of "Magic Objects"
&lt;/h4&gt;

&lt;p&gt;That comes as the narrative for the form of reactivity that these techniques enable, and the implication is in terms of the final model that these magic objects create: &lt;strong&gt;a system where observability is an &lt;em&gt;object-level feature&lt;/em&gt;, or in other words, an &lt;em&gt;object-level concern&lt;/em&gt;&lt;/strong&gt;! This comes with &lt;strong&gt;much complexity&lt;/strong&gt; and &lt;strong&gt;multiple points of failure at the granular level&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Being a concern at such a granular level of your architecture, "reactivity" now tends to govern every detail of your work: &lt;strong&gt;objects have to be purpose-built for observability&lt;/strong&gt;, &lt;strong&gt;and existing ones retrofitted&lt;/strong&gt;; &lt;strong&gt;and in all you do, you must be &lt;em&gt;explicit&lt;/em&gt; about reactivity&lt;/strong&gt;! And because &lt;em&gt;it is hard to gain and easy to lose&lt;/em&gt;, &lt;strong&gt;you also have to be conscious about how each object flows through your application&lt;/strong&gt;; and there lies &lt;em&gt;the footguns and bottlenecks&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tricky to account for across the various points of interaction!&lt;/strong&gt; Given a system where functionality relies on data and reactivity being bundled together and passed around together, it happens so easily that the latter is lost on transit without notice! That becomes a big problem in any fairly-sized codebase!&lt;br&gt;
 &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Accessors&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using the accessor-based ref() function in Vue.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;watchEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Reactivity gained&lt;/span&gt;
&lt;span class="nf"&gt;watchEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Count value changed:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;carelessHandling&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;delete&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;carelessHandling&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Reactivity lost&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;It turns out, any reactive system based on "magic objects" is susceptible to failure at the granular level! &lt;br&gt;
 &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tricky in dealing with object trees!&lt;/strong&gt; You couldn't gain reactivity beyond the surface without some form of recursive transformations, &lt;strong&gt;and yet all of that would still be subject to the assumption that your object tree is a &lt;em&gt;static&lt;/em&gt; structure&lt;/strong&gt;! Things get extra tricky this time because, in reality, &lt;strong&gt;that assumption isn't always the case&lt;/strong&gt;!&lt;br&gt;
 &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Proxies&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Using the depth-capable reactive() function in Vue.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;reactive&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Creating a reactive object tree&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reactiveTree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resourceUrl&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;reactive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Problem&lt;/span&gt;
&lt;span class="nx"&gt;reactiveTree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Turns out, any reactivity gained from stitching proxies or accessors together is most often than not &lt;em&gt;unpredictable&lt;/em&gt; and &lt;em&gt;rickety&lt;/em&gt;!&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  A Way to Think About the Problem
&lt;/h3&gt;

&lt;p&gt;Proxies and accessors constitute the only &lt;em&gt;native&lt;/em&gt; way today to do &lt;em&gt;mutation-based&lt;/em&gt; reactive programming - not particularly because they perfectly reflect the desired approach, but because they're the only native way! However, this isn't a case of poorly designed language features, &lt;strong&gt;this is rather about usecase mismatch&lt;/strong&gt;! Whereas proxies and accessors have their perfect usecases across the broader subject of meta programming, &lt;strong&gt;reactive programming represents a usecase not well captured&lt;/strong&gt;; or in other words: &lt;strong&gt;something that isn't very much their usecase&lt;/strong&gt;!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Proxies, for example, are mind blowing in what they can do across the broader subject of meta programming, having had a massive technical and academic work go into their design (as can been seen from &lt;a href="https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37741.pdf" rel="noopener noreferrer"&gt;ES-lab's original design document&lt;/a&gt;), and it is on this backdrop they seem to be the silver bullet to reactivity! But it turns out that &lt;strong&gt;it is on just a subset of that - typically something around three internal traps: &lt;code&gt;get&lt;/code&gt;, &lt;code&gt;set&lt;/code&gt;, &lt;code&gt;deleteProperty&lt;/code&gt;&lt;/strong&gt; - that we're building our reactive world, &lt;strong&gt;and well, the rest of which isn't fully captured in the design of proxies&lt;/strong&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While object observability as a technique may have an &lt;em&gt;overlap&lt;/em&gt; with the usecase for proxies and accessors, &lt;strong&gt;it isn't the main thing these were designed for, and these primitives conversely don't come ideal for the problem case&lt;/strong&gt;! If I were to represent that mathemaically, that would be 25% overlap, 75% mismatch:&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftm4uuzktux4d1qmb7fpp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftm4uuzktux4d1qmb7fpp.png" alt="Intersection between native primitives and reactivity" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This leaves us with a desire to find something made for the problem! And it turns out, this isn't the first time we're hitting this wall!&lt;/p&gt;
&lt;h3&gt;
  
  
  Rediscovering Prior Art and Nailing the Problem
&lt;/h3&gt;

&lt;p&gt;This is where history helps us!&lt;/p&gt;

&lt;p&gt;Amidst the remnants lies a design precedent to object observability waiting to be re-discovered: the &lt;a href="https://web.dev/es7-observe/" rel="noopener noreferrer"&gt;&lt;code&gt;Object.observe()&lt;/code&gt;&lt;/a&gt; API, which was depreciated in November 2015! It probably was ahead of its time, but in its 8 years in the mud, there's something time has taught us: &lt;strong&gt;&lt;em&gt;the platform needs native object observability&lt;/em&gt;, and it's okay to have things coexist for different usecases&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Consider the approach in this API:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Notice that, now, &lt;strong&gt;the tracking mechanism is &lt;em&gt;separate&lt;/em&gt; from the objects themselves&lt;/strong&gt;, and what's more, universal for every object! (It's much like the upgrade from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__" rel="noopener noreferrer"&gt;&lt;code&gt;.__defineSetter__()&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__" rel="noopener noreferrer"&gt;&lt;code&gt;.__defineGetter__()&lt;/code&gt;&lt;/a&gt; to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty" rel="noopener noreferrer"&gt;&lt;code&gt;Object.defineProperty()&lt;/code&gt;&lt;/a&gt;!) &lt;strong&gt;And this basically solves all of our problems today with primitives&lt;/strong&gt;!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now, we can put all of that "magic object" idea behind us: observability shouldn't have to be an object-level feature (or object-level concern)!

&lt;ul&gt;
&lt;li&gt;We no more have to be explicit about reactivity; or be governed by that concern!&lt;/li&gt;
&lt;li&gt;It shouldn't have to be gained or lost; or be passed around together with data!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now everything just works on the fly; no more upfront work nor dealing with internal traps!

&lt;ul&gt;
&lt;li&gt;No more patching objects, nor transforming object trees!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now we can interact with real objects across our codebase: things no more rely on intermediary functions or wrappers!

&lt;ul&gt;
&lt;li&gt;No more accounting for two different object identities or hacking around that!&lt;/li&gt;
&lt;li&gt;No more dealing with leaky, bypassable tracking mechanism!&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And doesn't that nail it? Why shouldn't we explore this further?&lt;/p&gt;

&lt;p&gt;Having struggled around object observability myself over the years, I find it necessary to re-explore this prior art today as a new project: &lt;strong&gt;the Observer API&lt;/strong&gt;!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing the Observer API
&lt;/h3&gt;

&lt;p&gt;This is a new effort that re-explores object observability along the lines of &lt;code&gt;Object.observe()&lt;/code&gt;, but this time, with a more wholistic approach! It takes a leap at what could be &lt;strong&gt;a unifying API&lt;/strong&gt; over &lt;em&gt;related but disparate&lt;/em&gt; APIs like &lt;code&gt;Object.observe()&lt;/code&gt;, the "Proxy traps" API, and the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect" rel="noopener noreferrer"&gt;Reflect&lt;/a&gt; API (which is a complementary API to proxies)!&lt;/p&gt;

&lt;p&gt;This is an upcoming proposal!&lt;/p&gt;
&lt;h4&gt;
  
  
  An Overview
&lt;/h4&gt;

&lt;p&gt;As an improvement over its original form - &lt;a href="https://web.dev/es7-observe/" rel="noopener noreferrer"&gt;&lt;code&gt;Object.observe()&lt;/code&gt;&lt;/a&gt;, the object observability API is being re-imagined!&lt;/p&gt;

&lt;p&gt;Whereas the previous API lived off the global "Object" object, the new idea is to have it on the global "Reflect" object as if being one of the missing pieces in a puzzle! (But this is subject to whether everything considered here still falls within the scope of the Reflect API.) But that's just one of two possibilitis considered! The other is to have it on a new Reflect-like object called &lt;code&gt;Observer&lt;/code&gt;, which is, this time, a fully-featured reactivity API!&lt;/p&gt;

&lt;p&gt;While that unfolds, a prototype of the Observer API exists today as &lt;code&gt;Observer&lt;/code&gt;, featuring a superset of each Reflect method in addition to other specialized APIs. Much of the code here is based on this &lt;code&gt;Observer&lt;/code&gt; namespace.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Observer API&lt;/th&gt;
&lt;th&gt;Reflect API&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;apply()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;apply()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;construct()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;construct()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;observe()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;-&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;set()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;set()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;setPrototypeOf()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;setPrototypeOf()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Being fully compatible with the Reflect API, the Observer API can be used today as a drop-in replacement for Reflect.&lt;/p&gt;

&lt;p&gt;To begin, here's the &lt;code&gt;observe()&lt;/code&gt; method:&lt;/p&gt;

&lt;p&gt;└ Signatures&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Observe all properties&lt;/span&gt;
&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Observe a list of properties&lt;/span&gt;
&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="nx"&gt;propertyName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="nx"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Observe a value&lt;/span&gt;
&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;propertyName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;└ Handler&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;mutations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;oldValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isUpdate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;From here, additional features become necessary! We discuss some of these here and link to the rest.&lt;/p&gt;
&lt;h4&gt;
  
  
  Featuring Path Observability
&lt;/h4&gt;

&lt;p&gt;A much needed feature for &lt;code&gt;Object.observe()&lt;/code&gt; was path observability! The void that initially having it left out created required much boilerplate to fill. A few polyfills at the time (e.g. Polymer's &lt;a href="https://github.com/googlearchive/observe-js" rel="noopener noreferrer"&gt;observe-js&lt;/a&gt;) took that to heart. And that certainly has a place in the new API!&lt;/p&gt;

&lt;p&gt;This time, instead of following a string-based "path" approach - &lt;code&gt;level1.level2&lt;/code&gt; - a path is represented by an array - a &lt;code&gt;Path&lt;/code&gt; array instance:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;An array allows us to support property names that themselves have a dot in them. And by using Observer's &lt;code&gt;Path&lt;/code&gt; array instance, we are able to distinguish between normal "property list" array - as seen earlier - and actual "path" array.&lt;/p&gt;

&lt;p&gt;The idea here is to observe "a value" at a path in a given tree:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A tree structure that satisfies the path above&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;level1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;level2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level2-value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isUpdate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level2-new-value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  Console
  &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;type&lt;/th&gt;
&lt;th&gt;path&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;th&gt;isUpdate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;[ &lt;code&gt;level1&lt;/code&gt;, &lt;code&gt;level2&lt;/code&gt;, ]&lt;/td&gt;
&lt;td&gt;&lt;code&gt;level2-new-value&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;true&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;/p&gt;

&lt;p&gt;And well, the initial tree structure can be whatever:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A tree structure that is yet to be built&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level4&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;Observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isUpdate&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now, any operation that changes what "the value" at the path resolves to - either by tree extension or tree truncation - will fire our listener:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;level2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  Console
  &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;type&lt;/th&gt;
&lt;th&gt;path&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;th&gt;isUpdate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;[ &lt;code&gt;level1&lt;/code&gt;, &lt;code&gt;level2&lt;/code&gt;, &lt;code&gt;level3&lt;/code&gt;, &lt;code&gt;level4&lt;/code&gt;, ]&lt;/td&gt;
&lt;td&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;/p&gt;

&lt;p&gt;Meanwhile, this next one completes the tree, and the listener reports a value at its observed path:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;level3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;level4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level4-value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  Console
  &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;type&lt;/th&gt;
&lt;th&gt;path&lt;/th&gt;
&lt;th&gt;value&lt;/th&gt;
&lt;th&gt;isUpdate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;set&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;[ &lt;code&gt;level1&lt;/code&gt;, &lt;code&gt;level2&lt;/code&gt;, &lt;code&gt;level3&lt;/code&gt;, &lt;code&gt;level4&lt;/code&gt;, ]&lt;/td&gt;
&lt;td&gt;&lt;code&gt;level4-value&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;false&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;/p&gt;

&lt;p&gt;If you were to find the exact point at which mutation happened in the path in an audit trail, use the event's &lt;code&gt;context&lt;/code&gt; property to inspect the parent event:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And up again one level until the root event:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;parentContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parentContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And you can observe trees that are built &lt;em&gt;asynchronously&lt;/em&gt;! Where a promise is encountered along the path, further access is paused until promise resolves:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;level2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;level3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;level4&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;level4-new-value&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Documentation
&lt;/h4&gt;

&lt;p&gt;Visit the &lt;a href="https://github.com/webqit/observer/wiki" rel="noopener noreferrer"&gt;docs&lt;/a&gt; for full details - including &lt;a href="https://github.com/webqit/observer/wiki#timing-and-batching" rel="noopener noreferrer"&gt;Timing and Batching&lt;/a&gt;, &lt;a href="https://github.com/webqit/observer/wiki#putting-it-all-together" rel="noopener noreferrer"&gt;full API Reference&lt;/a&gt;, and more.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Project
&lt;/h4&gt;

&lt;p&gt;The Observer API is being developed as something to be used today - via a polyfill. The polyfill features all of what's documented - with a few limitations!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/webqit" rel="noopener noreferrer"&gt;
        webqit
      &lt;/a&gt; / &lt;a href="https://github.com/webqit/observer" rel="noopener noreferrer"&gt;
        observer
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A simple set of functions for intercepting and observing JavaScript objects and arrays.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;The Observer API&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://npmjs.com/package/@webqit/observer" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/7c657cbdfcd27add83d92f56cc61d772a1acb4c8589d60e611667490d050a130/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f407765627169742f6f627365727665723f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="npm version"&gt;&lt;/a&gt;
&lt;a href="https://npmjs.com/package/@webqit/observer" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/6865f9764fe21da2c6c3b1eb5af1501f569a7259ea79ff37c556baabdaf8d900/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f407765627169742f6f627365727665723f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="npm downloads"&gt;&lt;/a&gt;
&lt;a href="https://bundlephobia.com/result?p=@webqit/observer" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/a41a3bcb7211f864e249bf5b6fc19371ec5a6ddaf9b2e14cbf3f6509d3dd9a79/68747470733a2f2f696d672e736869656c64732e696f2f62756e646c6570686f6269612f6d696e7a69702f407765627169742f6f627365727665723f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="bundle"&gt;&lt;/a&gt;
&lt;a href="https://github.com/webqit/observer/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/088e6d79e715dca7a4cb572abec365933fe657d5baf1029c9b392dd08e9d806f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7765627169742f6f627365727665722e7376673f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d463044423446" alt="License"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Observe and intercept operations on arbitrary JavaScript objects and arrays using a utility-first, general-purpose reactivity API!&lt;/p&gt;
&lt;p&gt;This API re-explores the unique design of the retired &lt;a href="https://web.dev/es7-observe/" rel="nofollow noopener noreferrer"&gt;Object.observe()&lt;/a&gt; API and unifies that with the rest of JavaScript's metaprogramming APIs: &lt;code&gt;Proxies&lt;/code&gt;, &lt;code&gt;Reflect&lt;/code&gt;, &lt;code&gt;Object&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;Observer comes as one little API for all things &lt;em&gt;object observability&lt;/em&gt;. (Only &lt;code&gt;~5.8KiB min|zip&lt;/code&gt;)&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;obj&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-c"&gt;// Observe all property changes&lt;/span&gt;
&lt;span class="pl-v"&gt;Observer&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;observe&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;obj&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;mutations&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-s1"&gt;mutations&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;forEach&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;mutation&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
    &lt;span class="pl-smi"&gt;console&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;log&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s"&gt;`&lt;span class="pl-s1"&gt;&lt;span class="pl-kos"&gt;${&lt;/span&gt;&lt;span class="pl-s1"&gt;mutation&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;type&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;/span&gt;: &lt;span class="pl-s1"&gt;&lt;span class="pl-kos"&gt;${&lt;/span&gt;&lt;span class="pl-s1"&gt;mutation&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;key&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;/span&gt; = &lt;span class="pl-s1"&gt;&lt;span class="pl-kos"&gt;${&lt;/span&gt;&lt;span class="pl-s1"&gt;mutation&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-c1"&gt;value&lt;/span&gt;&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;/span&gt;`&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
  &lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-v"&gt;Observer&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;set&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;obj&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s"&gt;'count'&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c1"&gt;5&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-v"&gt;Observer&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;deleteProperty&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;obj&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s"&gt;'oldProp'&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-alert markdown-alert-tip"&gt;
&lt;p class="markdown-alert-title"&gt;Tip&lt;/p&gt;
&lt;p&gt;Reactivity is anchored on its programmtic APIs…&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/webqit/observer" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Show support with a star on github! Also, all forms of contributions are welcome at this time.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;SECTION 2/3&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Re-Exploring the Language of Reactivity
&lt;/h2&gt;

&lt;p&gt;While we may have fixed object observability, &lt;strong&gt;we still need to find a way to actually write reactive logic - in how we normally would write JavaScript programs&lt;/strong&gt;! There's a big difference here, and it's like the difference between playing individual musical notes and composing a song!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But while this constitutes a different problem from what object observability solves, they've got be related, and that's definitely where this journey culminates!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Come to writing application logic...&lt;/p&gt;

&lt;p&gt;Here is how we learned to write applicatons (notice: in normal, imperative JavaScript):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and the challenge for reactive programming is to find a way to express the same such that the logic...&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;...continues to hold even when a part of the dependency chain is updated!&lt;/p&gt;

&lt;p&gt;This magic by itself has had no formal language, yet it has managed to become the most spoken &lt;em&gt;language&lt;/em&gt; on the frontend today! But unfortunately, &lt;strong&gt;reactivity is a &lt;em&gt;difficult&lt;/em&gt; language to speak:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This has involved compiler-driven syntaxes and whole new &lt;a href="https://en.wikipedia.org/wiki/Domain-specific_language" rel="noopener noreferrer"&gt;DSLs&lt;/a&gt;, and on a more general note, making the shift to writing applications under an &lt;em&gt;entirely different&lt;/em&gt; programming paradigm: &lt;a href="https://en.wikipedia.org/wiki/Functional_programming" rel="noopener noreferrer"&gt;Functional Programming&lt;/a&gt;! And there lies the big problem for the average developer: &lt;strong&gt;that &lt;em&gt;paradigm shift&lt;/em&gt; from "normal" JavaScript&lt;/strong&gt;!&lt;/p&gt;



&lt;p&gt;It just happens that there's no easy way around the idea! And when you look: &lt;strong&gt;what &lt;em&gt;always&lt;/em&gt; goes for reactivity is syntax and mental model&lt;/strong&gt;! Only, some approaches can be considered better off than others on either of those factors.&lt;/p&gt;
&lt;h3&gt;
  
  
  The Toll On Syntax and Mental Model
&lt;/h3&gt;

&lt;p&gt;Enter the typical language of reactivity: Functional Programming...&lt;/p&gt;

&lt;p&gt;Whereas imperative programs are written in &lt;strong&gt;literal terms&lt;/strong&gt; and are based on a &lt;strong&gt;linear execution flow&lt;/strong&gt; (a sequential, line-by-line evaluation of statements and control flow structures), functional programming requires a series of change detection primitives to model the given application logic!&lt;/p&gt;

&lt;p&gt;Given our sample program in context, here's what the "functional" equivalent could look like across frameworks, using a pretty identical set of primitives:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;React&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// count&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// doubleCount&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="c1"&gt;// console.log()&lt;/span&gt;
&lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;SolidJS&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createSignal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createMemo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;createEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;solid-js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// count&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createSignal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// doubleCount&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console.log()&lt;/span&gt;
&lt;span class="nf"&gt;createEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Vue.js&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;watchEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// count&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// doubleCount&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console.log()&lt;/span&gt;
&lt;span class="nf"&gt;watchEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Svelte&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;derived&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;svelte/store&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// count&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// doubleCount&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;derived&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;$count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console.log()&lt;/span&gt;
&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;MobX&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;observable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;autorun&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mobx&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// count&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;observable&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;box&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// doubleCount&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// console.log()&lt;/span&gt;
&lt;span class="nf"&gt;autorun&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;What do we have here? A common reactive language, and, well, the problem case: &lt;strong&gt;a &lt;em&gt;programming paradigm&lt;/em&gt; shift&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;What is in traditional JavaScript a literal variable declaration is in the functional approach a very different type of declaration:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Variable&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;one&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;two&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Read/write segregation&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setItems&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createSignal&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;one&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;two&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Also, what is to traditional JavaScript a "mutable" world is to the functional approach an "immutable" world (or you end up defying the reactivity system):&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Mutation world&lt;/span&gt;
&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;three&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Immutable world&lt;/span&gt;
&lt;span class="nf"&gt;setItems&lt;/span&gt;&lt;span class="p"&gt;([...&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;three&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And the story goes the same for conditional constructs, loops, etc.!&lt;/p&gt;

&lt;p&gt;The focus entirely shifts now from writing idiomatic JavaScript to following paradigm-specific constraints, and in addition, other implementation-specific details:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the Signals family: &lt;a href="https://dev.to/this-is-learning/making-the-case-for-signals-in-javascript-4c7i#ok-but-what-about-the-tradeoffs"&gt;that technique around fine-grained reactivity&lt;/a&gt; - wherein you have to carefully craft, or "&lt;a href="https://dev.to/ryansolid/comment/256gh"&gt;group&lt;/a&gt;", logic "around data flow" to actually stay fine-grained. Also, &lt;a href="https://twitter.com/acdlite/status/1628930249718202369#:~:text=we%20don't%20like%20the%20code%20you%20have%20to%20write%20to%20get%20it." rel="noopener noreferrer"&gt;that extra invokation syntax&lt;/a&gt; - &lt;code&gt;count()&lt;/code&gt;, &lt;code&gt;count.get()&lt;/code&gt;, &lt;code&gt;count.value&lt;/code&gt; - that goes with what was supposed to be a literal variable.&lt;/li&gt;
&lt;li&gt;In the Hooks family (React, Preact): &lt;a href="https://twitter.com/sebinsua/status/1628861236925407235" rel="noopener noreferrer"&gt;the underestimated &lt;em&gt;dependency&lt;/em&gt; array&lt;/a&gt;, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this on top of the required diligence needed to manually model the control flow and dependency graph of your application logic - by piecing together multiple primitives! Anyone who's been there can tell how the many &lt;em&gt;moving parts&lt;/em&gt; and high amount of &lt;em&gt;abstraction&lt;/em&gt; and &lt;em&gt;indirection&lt;/em&gt; &lt;strong&gt;significantly impact the authoring experience and cognitive load&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;It turns out that this is a problem with any "runtime" magic as there must always be a thing to put up with: &lt;strong&gt;syntax noise and other ergonomic overheads&lt;/strong&gt;, &lt;strong&gt;a difficult-to-grok execution model and other cognitive overheads&lt;/strong&gt;, etc.!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This has been a strong enough case across frameworks that everyone has had to support their "functional" magic with some other type of magic that tries to solve either for syntax or for mental model!&lt;/strong&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Solving for Syntax
&lt;/h4&gt;

&lt;p&gt;Vue, for example, will help you &lt;a href="https://vuejs.org/guide/essentials/reactivity-fundamentals.html#ref-unwrapping-in-templates" rel="noopener noreferrer"&gt;automatically unwrap&lt;/a&gt; certain refs used in &lt;code&gt;.vue&lt;/code&gt; templates, and in a few other contexts. (The idea even made it as a more extensive &lt;a href="https://vuejs.org/guide/extras/reactivity-transform.html" rel="noopener noreferrer"&gt;syntax transform&lt;/a&gt; project!) Similarly, in React, &lt;a href="https://www.youtube.com/watch?v=lGEMwh32soc&amp;amp;t=2s" rel="noopener noreferrer"&gt;work is underway&lt;/a&gt; to &lt;a href="https://twitter.com/acdlite/status/1628862794572374019" rel="noopener noreferrer"&gt;put memoization and more&lt;/a&gt; behind a compiler!&lt;/p&gt;

&lt;p&gt;Svelte stands out here as it goes full-blown with the idea of a compiler to let you write whole logic in literal, imperative JavaScript in &lt;code&gt;.svelte&lt;/code&gt; templates, on top of its "functional" core:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Double&lt;/span&gt; &lt;span class="nx"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/main&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Only, it suffers from being unintuitive by the "twist" - the magic - that went into it: compiling from &lt;em&gt;literal&lt;/em&gt;, &lt;em&gt;linear&lt;/em&gt; syntax to a &lt;em&gt;functional&lt;/em&gt;, &lt;em&gt;non-linear&lt;/em&gt; execution model, thus defying the general expectation of the "&lt;a href="https://en.wikipedia.org/wiki/Imperative_programming" rel="noopener noreferrer"&gt;imperative&lt;/a&gt;" paradigm it appears to go by!&lt;/p&gt;

&lt;p&gt;For example, as documented:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// this will update `name` when 'person' changes&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// don't do this. it will run before the previous line&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And you can see that again here in how the program seems to go bottom-up:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 20&lt;/span&gt;

&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;There goes the non-linear execution model behind the imperative syntax! So, it turns out, what you get isn't &lt;em&gt;what you see&lt;/em&gt; when you look in the face of your code, but &lt;em&gt;what's documented&lt;/em&gt;! Indeed, Svelte scripts "are nothing like 'plain JavaScript' yet people seem to be accepting of those and some even advertising them as such." - &lt;a href="https://dev.to/this-is-learning/the-quest-for-reactivescript-3ka3#:~:text=svelte's%20scripts%20are%20nothing%20like%20%22plain%20javascript%22%20yet%20people%20seem%20to%20be%20accepting%20of%20those%20and%20some%20even%20advertising%20them%20as%20such."&gt;Ryan Carniato&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nonetheless, Svelte's vision underscores &lt;strong&gt;the strong case for less ergonomic overheads in &lt;em&gt;plain&lt;/em&gt;, &lt;em&gt;literal&lt;/em&gt; syntax&lt;/strong&gt; - the bar that every "syntax" quest actually has in front of them! &lt;strong&gt;Only, this cannot be rational with a &lt;em&gt;functional&lt;/em&gt;, &lt;em&gt;non-linear&lt;/em&gt; core - as seen from its current realities&lt;/strong&gt;!&lt;/p&gt;
&lt;h4&gt;
  
  
  Solving for Mental Model
&lt;/h4&gt;

&lt;p&gt;React has long stood on what they consider a "simpler" rendering model:&lt;/p&gt;

&lt;p&gt;Whereas in normal functional programming, changes propagate from function to function as explicitly modelled, React deviates from the idea in its "hooks" approach for a model where changes don't propagate from function to function as explicitly modelled, but propagate directly to the "component" and trigger a full "top-down" re-render of the component - giving us a "top-down" rendering model!&lt;/p&gt;

&lt;p&gt;The pitch here is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"You don't have to think about how updates flow through your UI anymore! Just rerender the whole thing and we'll make it fast enough."&lt;/em&gt; - &lt;a href="https://twitter.com/acdlite/status/1628811936522543104" rel="noopener noreferrer"&gt;Andrew Clark&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And in relation to Signals:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"That's why I don't buy the argument that signals provide a better DX/mental model."&lt;/em&gt; - &lt;a href="https://twitter.com/acdlite/status/1628811937797574657" rel="noopener noreferrer"&gt;Andrew Clark&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which from this standpoint should remain highly-protected:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I think you guys should be way more aggressive in pushing back against this stuff. Throwing out the react programming model and adopting something like signals (or worse, signals plus a dsl) is a huge step backwards and most people haven’t internalized that."&lt;/em&gt; - &lt;a href="https://twitter.com/floydophone/status/1629009165422104576" rel="noopener noreferrer"&gt;Pete Hunt&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And when you look, you see a vision here for &lt;strong&gt;a "linear" execution model&lt;/strong&gt;, much like the linear "top-down" flow of regular programs!&lt;/p&gt;

&lt;p&gt;Only, it suffers from being counterintuitive by itself with the "twist" - the magic - that went into it: defying the general expectation of the "&lt;a href="https://en.wikipedia.org/wiki/Functional_programming" rel="noopener noreferrer"&gt;functional&lt;/a&gt;" paradigm it appears to go by! So, it turns out, what you get isn't &lt;em&gt;what you see&lt;/em&gt; when you look in the face of your code, but &lt;em&gt;what's documented&lt;/em&gt;, which for many devs makes the Signals approach &lt;em&gt;more grokable&lt;/em&gt;, wherein "functional" is "functional":&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"its funny, the first time i ever used signals wasn't for perf, it was for understanding where change happens easier.  plus you get LSP references to change.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;just seems.... most rational"&lt;/em&gt; - &lt;a href="https://twitter.com/ThePrimeagen/status/1629221580344532992" rel="noopener noreferrer"&gt;ThePrimeagen&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Being as it may:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"The React thought leadership had long cultivated the narrative of 'our model is more correct', almost becoming a dogma. In reality, many engineers are simply more productive with the signals mental model - arguing on a philosophical level is pointless when that happens."&lt;/em&gt; - &lt;a href="https://twitter.com/youyuxi/status/1631089471377801216" rel="noopener noreferrer"&gt;Evan You&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And the whole idea seems to fall short again with the extra &lt;a href="https://twitter.com/acdlite/status/1628862794572374019" rel="noopener noreferrer"&gt;useMemo/useCallback&lt;/a&gt; performance hack needed to control the "re-render" mdoel!&lt;/p&gt;

&lt;p&gt;Nonetheless, React's vision underscores &lt;strong&gt;the strong case for less mental overheads in terms of a &lt;em&gt;linear&lt;/em&gt; execution model&lt;/strong&gt; - the very thing we hope to regain someday! &lt;strong&gt;Only, this doesn't seem to be what function primitives can provide rationally - as seen from its current realities&lt;/strong&gt;!&lt;/p&gt;
&lt;h4&gt;
  
  
  Solving for Both
&lt;/h4&gt;

&lt;p&gt;Given the ongoing quest for reactivity without the ergonomic and mental overheads, the &lt;em&gt;new bar&lt;/em&gt; for reactivity is to &lt;strong&gt;not solve for one and fall short on the other&lt;/strong&gt;! We may not be hitting the mark in a single implmenentation now, but not until &lt;a href="https://twitter.com/trueadm/status/1628866012786327552" rel="noopener noreferrer"&gt;more and more people&lt;/a&gt; discover the power of compilers and make the full shift!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Smart compilers will be the next big shift. It needs to happen. Look at the optimization and wizardry of modern C compilers. The web needs similar sophistication so we can maintain simpler mental models but get optimized performance."&lt;/em&gt; - &lt;a href="https://twitter.com/matt_kruse/status/1626654945775689729?s=20" rel="noopener noreferrer"&gt;Matt Kruse&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In their ability to take a piece of code and generate a different piece altogether, &lt;strong&gt;compilers give us a blank check to write the code we want and get back the equivalent code for a particular problem&lt;/strong&gt;, becoming the hugest prospect for reactive programming! Soon on the Language of Reactivity, we may never again talk about "functional" primitives or "functional" core! And there's only one place this leads: &lt;strong&gt;reactivity in just plain JavaScript; this time, in the &lt;em&gt;literal form&lt;/em&gt; and &lt;em&gt;linear flow&lt;/em&gt; of the language&lt;/strong&gt;!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"It’s building a compiler that understands the data flow of arbitrary JS code in components.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Is that hard? Yeah!&lt;/em&gt;&lt;br&gt;
&lt;em&gt;Is it possible? Definitely.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;And then we can use it for so many things…"&lt;/em&gt; - &lt;a href="https://twitter.com/sophiebits/status/1628952004725989377" rel="noopener noreferrer"&gt;sophie alpert&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;There goes the &lt;em&gt;final bar&lt;/em&gt; for reactivity!&lt;/strong&gt; It is what you see given half the vision in Svelte: "syntax" (assuming a path fully explored to the end) and half the vision in React: "top-down flow" (assuming a path fully explored to the end); the point where all quests on the Language of Reactivity culminate!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsd30oj6p8jv2i8e3k7na.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsd30oj6p8jv2i8e3k7na.png" alt="Culmination of various quests in reactivity" width="800" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But what if &lt;em&gt;everything in this "reactivity of the future" thesis was possible today&lt;/em&gt;, and what's more, &lt;em&gt;without the compile step&lt;/em&gt;?&lt;/p&gt;
&lt;h3&gt;
  
  
  Bringing Reactivity to Imperative JavaScript and Nailing the Problem
&lt;/h3&gt;

&lt;p&gt;You'd realize that the idea of "building a compiler that understands arbitrary JS code" is synonymous to bringing reactivity to "arbitrary" JavaScript, &lt;strong&gt;and if we could achieve that, we could literaly have reactivity as a native language feature&lt;/strong&gt;! Now this changes everything because &lt;strong&gt;that wouldn't be a compiler thing anymore&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Can we skip now to that fun part?&lt;/p&gt;

&lt;p&gt;We explore this by revisiting where we've fallen short of &lt;em&gt;bringing reactivity to "arbitrary" JavaScript&lt;/em&gt; and fixing that! Svelte comes as a good starting point:&lt;/p&gt;

&lt;p&gt;In Svelte today, reactivity is based on the custom &lt;code&gt;.svelte&lt;/code&gt; file extension! (Being what carries the idea of a &lt;em&gt;reactive programming context&lt;/em&gt; in the application!)&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;calculate.svelte&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;// Code here&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  But what if we could bring that &lt;em&gt;reactive programming context&lt;/em&gt; to a function...
  &lt;br&gt;
...for a handy building block that can be easily composed into other things?&lt;br&gt;


&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Code here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And next is how you express reactivity!&lt;/p&gt;

&lt;p&gt;That, in Svelte today, relies on the dollar sign &lt;code&gt;$&lt;/code&gt; label - being another type of manual dependency plumbing, albeit subtle:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 20&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  But what if we simply treated every expression as &lt;em&gt;potentially&lt;/em&gt; reactive...
  &lt;br&gt;
...having already moved into a reactive programming context?&lt;br&gt;


&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 20&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And lastly, the execution model!&lt;/p&gt;

&lt;p&gt;Updates propagate in Svelte today "functionally", and thus, in any direction, to any part of the program:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 40&lt;/span&gt;
&lt;span class="c1"&gt;// Update&lt;/span&gt;
&lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  But what if we could get updates to propagate "top-down" the program...
  &lt;br&gt;
...and actually regain the "top-down" linear flow of &lt;em&gt;actual&lt;/em&gt; imperative programs?&lt;br&gt;


&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 20&lt;/span&gt;
  &lt;span class="c1"&gt;// Update&lt;/span&gt;
  &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Well, notice now that the update to &lt;code&gt;count&lt;/code&gt; in the last line wouldn't be reactive! And that brings us to the question: &lt;strong&gt;does anything ever react to anything in this model&lt;/strong&gt;? The answer lies in what "dependencies" mean in normal programs!&lt;/p&gt;

&lt;p&gt;Conventionally, programs run in sequential, linear flow, along which references to "prior" identifiers in scope create "dependencies"! This means that &lt;strong&gt;statements should &lt;em&gt;really&lt;/em&gt; only be responding to changes happening &lt;em&gt;up the scope&lt;/em&gt;, not down the scope&lt;/strong&gt; (as the case may be in Svelte today)! And that for a function scope would be: &lt;strong&gt;changes happening "outside" the scope&lt;/strong&gt; - up to the global scope!&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// External dependency&lt;/span&gt;
  &lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 20&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;count&lt;/code&gt; is now a dependency from "up"/"outside" the function scope - by which reactivity inside the function scope is achieved! But what would that even look like?&lt;/p&gt;

&lt;p&gt;Imagine where the function has the ability to just "statically" reflect updates to its external dependencies:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// An update&lt;/span&gt;
&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// A hypothetical function&lt;/span&gt;
&lt;span class="nf"&gt;reflect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "count" being what the function sees&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;not particularly in their being a &lt;em&gt;parameter&lt;/em&gt;, but particularly in their being a dependency:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// External dependency&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubleCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubleCount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 20&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// An update&lt;/span&gt;
&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// A hypothetical function&lt;/span&gt;
&lt;span class="nf"&gt;reflect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "count" being what the function sees&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And that brings us to our destination - this point where we've checked all the boxes; where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The "reactive programming context" isn't some file, but a function - a handy new "reactivity primitive"!&lt;/li&gt;
&lt;li&gt;Reactivity isn't some special language or special convention, but &lt;em&gt;just JavaScript&lt;/em&gt; - the only real place you'd arrive if you tried!&lt;/li&gt;
&lt;li&gt;Execution model isn't anything "functional" by which we defy the semantics of &lt;em&gt;literal&lt;/em&gt; syntax, but "linear" - just in how imperative JavaScript works!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this in real life is &lt;strong&gt;Reflex Functions&lt;/strong&gt;!&lt;/p&gt;
&lt;h3&gt;
  
  
  Introducing Reflex Functions
&lt;/h3&gt;

&lt;p&gt;Reflex Functions are a new type of JavaScript function that enables fine-grained Reactive Programming in the &lt;em&gt;imperative&lt;/em&gt; form of the language - wherein reactivity is drawn entirely on the dependency graph of your own code!&lt;/p&gt;

&lt;p&gt;This is an upcoming proposal! (&lt;a href="https://en.wikipedia.org/wiki/Reactive_programming#Imperative" rel="noopener noreferrer"&gt;Introducing Imperative Reactive Programming&lt;/a&gt; (IRP) in JavaScript!)&lt;/p&gt;
&lt;h4&gt;
  
  
  An Overview
&lt;/h4&gt;

&lt;p&gt;Reflex Functions have a distinguishing syntax: a double star notation.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Function body&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;See &lt;a href="https://github.com/webqit/reflex-functions/wiki#formal-syntax" rel="noopener noreferrer"&gt;Formal Syntax&lt;/a&gt; for details.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Function body is any regular piece of code that should statically reflect changes to its external dependencies:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// External dependency&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;factor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Reactive expressions&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;doubled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;factor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;doubled&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Return value is a two-part array that contains both the function's actual return value and a special &lt;code&gt;reflect&lt;/code&gt; function for getting the function to reflect updates:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="nx"&gt;returnValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;reflect&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;returnValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  Console
  &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;doubled&lt;/th&gt;
&lt;th&gt;returnValue&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;20&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;reflect()&lt;/code&gt; function takes just the string representation of the external dependencies that have changed:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;reflect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;
  Console
  &lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;doubled&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;40&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;



&lt;/p&gt;

&lt;p&gt;Path dependencies are expressed in array notation. And multiple dependencies can be reflected at once, if they changed at once:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;property&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nf"&gt;reflect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;count&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;this&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;property&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Change Propagation
&lt;/h4&gt;

&lt;p&gt;Reactivity exists with Reflex Functions where there are dependencies "up" the scope to respond to! And here's the mental model for that:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;┌─&lt;/code&gt; a change &lt;em&gt;happens outside&lt;/em&gt; of function scope&lt;/p&gt;

&lt;p&gt;&lt;code&gt;└─&lt;/code&gt; is &lt;em&gt;propagated into&lt;/em&gt; function, then &lt;em&gt;self-propagates down&lt;/em&gt; &lt;code&gt;─┐&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Changes within the function body itself &lt;em&gt;self-propagate&lt;/em&gt; down the scope, but re-running only those expressions that depend on the specific change, and rippling down the dependency graph!&lt;/p&gt;

&lt;p&gt;Below is a good way to see that: a Reflex Function having &lt;code&gt;score&lt;/code&gt; as an external dependency, with "reflex lines" having been drawn to show the dependency graph for that variable, or, in other words, the deterministic update path for that dependency:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgh6r6qb1pamvwy22fgqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgh6r6qb1pamvwy22fgqv.png" alt="Code with reflex lines" width="800" height="872"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;It turns out to be the very mental model you would have drawn if you set out to think about your own code! Everything works &lt;strong&gt;in just how anyone would &lt;em&gt;predict&lt;/em&gt; it&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Plus, there's a hunble brag: that "pixel-perfect" level of fine-grained reactivity that the same algorithm translates to - which you could never model manually; that precision that means &lt;em&gt;no more&lt;/em&gt;, &lt;em&gt;no less&lt;/em&gt; performance - which you could never achieve with manual optimization; yet, all without working for it!&lt;/p&gt;
&lt;h4&gt;
  
  
  Documentation
&lt;/h4&gt;

&lt;p&gt;Visit the &lt;a href="https://github.com/webqit/reflex-functions/wiki" rel="noopener noreferrer"&gt;docs&lt;/a&gt; for details around &lt;a href="https://github.com/webqit/reflex-functions/wiki#formal-syntax" rel="noopener noreferrer"&gt;Formal Syntax&lt;/a&gt;, &lt;a href="https://github.com/webqit/reflex-functions/wiki#heuristics" rel="noopener noreferrer"&gt;Heuristics&lt;/a&gt;, &lt;a href="https://github.com/webqit/reflex-functions/wiki#flow-control" rel="noopener noreferrer"&gt;Flow Control&lt;/a&gt; and &lt;a href="https://github.com/webqit/reflex-functions/wiki#functions" rel="noopener noreferrer"&gt;Functions&lt;/a&gt;, &lt;a href="https://github.com/webqit/reflex-functions/wiki#api" rel="noopener noreferrer"&gt;API&lt;/a&gt;, and more.&lt;/p&gt;
&lt;h4&gt;
  
  
  The Project
&lt;/h4&gt;

&lt;p&gt;Reflex Functions is being developed as something to be used today - via a polyfill. The polyfill features a specialized compiler and a small &lt;em&gt;runtime&lt;/em&gt; that work together to enable all of Reflex Functions as documented, with quite a few exceptions.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/webqit" rel="noopener noreferrer"&gt;
        webqit
      &lt;/a&gt; / &lt;a href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;
        quantum-js
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A runtime extension to JavaScript that unlocks Imperative Reactive Programming (IRP) in JavaScript!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Quantum JS&lt;/h1&gt;
&lt;/div&gt;

&lt;p&gt;&lt;a href="https://npmjs.com/package/@webqit/quantum-js" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/593fe8d376e3358f83766671ced3b749fcda737f0b9dc491353fb37d0048ec41/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f407765627169742f7175616e74756d2d6a733f7374796c653d666c617426636f6c6f72413d626c61636b26636f6c6f72423d463044423446" alt="npm version"&gt;&lt;/a&gt;
&lt;a href="https://bundlephobia.com/result?p=@webqit/quantum-js" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/169f75bac9afdbd54fe5c934628aa8b75e9a1918115b84802aa4f57c8e177161/68747470733a2f2f696d672e736869656c64732e696f2f62756e646c6570686f6269612f6d696e7a69702f407765627169742f7175616e74756d2d6a733f7374796c653d666c617426636f6c6f72413d626c61636b26636f6c6f72423d463044423446" alt="bundle"&gt;&lt;/a&gt;
&lt;a href="https://github.com/webqit/quantum-js/blob/master/LICENSE" rel="noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/2d0c217db75d22005de49f8dcbcc7e93a02b8d6fb0296e70ec272d46f0ed5863/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7765627169742f7175616e74756d2d6a732e7376673f7374796c653d666c617426636f6c6f72413d626c61636b26636f6c6f72423d463044423446" alt="License"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/webqit/quantum-js#overview" rel="noopener noreferrer"&gt;Overview&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#creating-quantum-programs" rel="noopener noreferrer"&gt;Creating Quantum Programs&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#implementation" rel="noopener noreferrer"&gt;Implementation&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#examples" rel="noopener noreferrer"&gt;Examples&lt;/a&gt; • &lt;a href="https://github.com/webqit/quantum-js#license" rel="noopener noreferrer"&gt;License&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Quantum JS is a runtime extension to JavaScript that brings Imperative Reactive Programming to JavaScript!&lt;/p&gt;
&lt;p&gt;What's that?&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Where you normally would require certain reactive primitives to express reactive logic...&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;// Import reactive primitives&lt;/span&gt;
&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt; &lt;span class="pl-s1"&gt;createSignal&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;createMemo&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;createEffect&lt;/span&gt; &lt;span class="pl-kos"&gt;}&lt;/span&gt; &lt;span class="pl-k"&gt;from&lt;/span&gt; &lt;span class="pl-s"&gt;'solid-js'&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;

&lt;span class="pl-c"&gt;// Declare values&lt;/span&gt;
&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-kos"&gt;[&lt;/span&gt; &lt;span class="pl-s1"&gt;count&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-s1"&gt;setCount&lt;/span&gt; &lt;span class="pl-kos"&gt;]&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;createSignal&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-c1"&gt;5&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-k"&gt;const&lt;/span&gt; &lt;span class="pl-s1"&gt;doubleCount&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-en"&gt;createMemo&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-s1"&gt;count&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;*&lt;/span&gt; &lt;span class="pl-c1"&gt;2&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-c"&gt;// Log this value live&lt;/span&gt;
&lt;span class="pl-en"&gt;createEffect&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-kos"&gt;{&lt;/span&gt;
  &lt;span class="pl-smi"&gt;console&lt;/span&gt;&lt;span class="pl-kos"&gt;.&lt;/span&gt;&lt;span class="pl-en"&gt;log&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-s1"&gt;doubleCount&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;
&lt;span class="pl-kos"&gt;}&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;// Setup periodic updates&lt;/span&gt;
&lt;span class="pl-en"&gt;setInterval&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt; &lt;span class="pl-c1"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="pl-en"&gt;setCount&lt;/span&gt;&lt;span class="pl-kos"&gt;(&lt;/span&gt;&lt;span class="pl-c1"&gt;10&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;,&lt;/span&gt; &lt;span class="pl-c1"&gt;1000&lt;/span&gt;&lt;span class="pl-kos"&gt;)&lt;/span&gt;&lt;span class="pl-kos"&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Quantum JS lets you acheive the same in the ordinary imperative form of the language:&lt;/p&gt;
&lt;div class="highlight highlight-source-js notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;// Declare values&lt;/span&gt;
&lt;span class="pl-k"&gt;let&lt;/span&gt; &lt;span class="pl-s1"&gt;count&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;5&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/webqit/quantum-js" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Show support with a star on github! Also, all forms of contributions are welcome at this time.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;SECTION 3/3&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Duo and the Prospect for Reactivity
&lt;/h2&gt;

&lt;p&gt;The magic that drives Frontend has got all the more powerful and completely intuitive!&lt;/p&gt;

&lt;p&gt;From where I am sitting, I can see the amount of heavy-lifting that the Observer API will do for large swaths of today's usecases for "internal traps" and the whole "magic objects" idea! (It's probably time for &lt;a href="https://web.dev/es7-observe/#:~:text=a%20revolution%20is%20coming." rel="noopener noreferrer"&gt;that "revolution" that never took off&lt;/a&gt;!)&lt;/p&gt;

&lt;p&gt;And we've certainly needed language support for &lt;em&gt;reactive logic&lt;/em&gt;! Think of the different proposals out there around JavaScript-XML-like DSLs - which of course don't translate well to a native ECMAScript feature! And consider how much we've had to rely on compilers today for the idea!&lt;/p&gt;

&lt;p&gt;Now that we can get "arbitrary" JavaScript to be reactive with Reflex Functions, a huge amount of that can be met natively! I am more than excited at how much we can regain &lt;em&gt;using just JavaScript&lt;/em&gt; in each of those areas where we've relied on tooling!&lt;/p&gt;

&lt;p&gt;I presume that experimenting around these new ideas, using the polyfill in each case, will furnish us new learnings around the problem! &lt;em&gt;For now, I am happy to have started the conversation&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;Now, did you know that these two reactive primitives could individually, or together, solve very unlikely problems? Here's where you can find early examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/webqit/reflex-functions#usecases" rel="noopener noreferrer"&gt;Reflex Functions / Usecases&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you'd find this an interesting idea, feel free to share!&lt;/p&gt;




&lt;h2&gt;
  
  
  Acknowledgements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Much thanks to &lt;a href="https://twitter.com/DavidBruant" rel="noopener noreferrer"&gt;David Bruant&lt;/a&gt;, &lt;a href="https://twitter.com/WebReflection" rel="noopener noreferrer"&gt;Andrea Giammarchi&lt;/a&gt;, and others for the various feedbacks and insights on early drafts of this article.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://vuejs.org/guide/extras/reactivity-in-depth.html#what-is-reactivity" rel="noopener noreferrer"&gt;What is reactivity?&lt;/a&gt; - a Vue.js definition&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.builder.io/blog/history-of-reactivity" rel="noopener noreferrer"&gt;A Brief History of Reactivity&lt;/a&gt; - a Miško Hevery narrative&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://web.dev/es7-observe/" rel="noopener noreferrer"&gt;&lt;code&gt;Object.observe()&lt;/code&gt;&lt;/a&gt; - web.dev&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37741.pdf" rel="noopener noreferrer"&gt;On the design of the ECMAScript Reflection API&lt;/a&gt; - ES-Lab&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://tvcutsem.github.io/js-membranes" rel="noopener noreferrer"&gt;What is a membrane?&lt;/a&gt; - Tom van Cutsem&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/salesforce/observable-membrane" rel="noopener noreferrer"&gt;Observable Membrane&lt;/a&gt; - Salesforce&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/ryansolid/a-hands-on-introduction-to-fine-grained-reactivity-3ndf"&gt;A Hands-on Introduction to Fine-Grained Reactivity&lt;/a&gt; - Ryan Carniato&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/this-is-learning/the-quest-for-reactivescript-3ka3"&gt;The Quest for ReactiveScript&lt;/a&gt; - Ryan Carniato&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=AdNJ3fydeao" rel="noopener noreferrer"&gt;Rethinking Reactivity&lt;/a&gt; - Rich Harris&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=lGEMwh32soc&amp;amp;t=2s" rel="noopener noreferrer"&gt;React Forget&lt;/a&gt; - React&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vuejs.org/guide/extras/reactivity-transform.html" rel="noopener noreferrer"&gt;Reactivity Transform&lt;/a&gt; - Vue.js&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tooling</category>
      <category>webqit</category>
    </item>
    <item>
      <title>Rethinking the Modern Web</title>
      <dc:creator>Oxford Harrison</dc:creator>
      <pubDate>Sun, 12 Feb 2023 21:40:13 +0000</pubDate>
      <link>https://forem.com/oxharris/rethinking-the-modern-web-5cn1</link>
      <guid>https://forem.com/oxharris/rethinking-the-modern-web-5cn1</guid>
      <description>&lt;p&gt;Frontend has an engineering problem!&lt;/p&gt;

&lt;p&gt;It is one field that has forged about the most enviable tooling ecosystem by roughly every measure - from growth rate to technical wizardry - and along with that an incredible amount of thought leadership on its every move,&lt;/p&gt;

&lt;p&gt;and yet at its bottom line:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the average website performance is only regressing with us!&lt;/li&gt;
&lt;li&gt;the average developer productivity is only grinding to a halt!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So it turns out, all of that "vibrant ecosystem" isn't really translating to more "accessible", "functional" apps on the &lt;em&gt;user&lt;/em&gt; front, and neither to more "speed" and "productivity" on the &lt;em&gt;developer&lt;/em&gt; front!&lt;/p&gt;

&lt;p&gt;The closer you get to Frontend's bottlenecks and to how much of that is tooling-induced the more you are wondering if we just have created more problems with our tools than we've solved!&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
The Counterintuitive Equations!

&lt;ul&gt;
&lt;li&gt;...on the user front&lt;/li&gt;
&lt;li&gt;...on the developer front&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Looking Back: The Paradigm Shift!

&lt;ul&gt;
&lt;li&gt;...from HTML to JavaScript&lt;/li&gt;
&lt;li&gt;...from the web platform to abstractions&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Towards a Faster Web: A New Quest!&lt;/li&gt;

&lt;li&gt;

Introducing: Web-Native Development!

&lt;ul&gt;
&lt;li&gt;Explore with Me...&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Notes&lt;/li&gt;

&lt;li&gt;Acknowledgements&lt;/li&gt;

&lt;li&gt;References&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Counterintuitive Equations!
&lt;/h2&gt;

&lt;p&gt;Consider how self-defeating it gets...&lt;/p&gt;

&lt;h3&gt;
  
  
  ...on the &lt;em&gt;user&lt;/em&gt; front
&lt;/h3&gt;

&lt;p&gt;Given &lt;a href="https://infrequently.org/2017/10/can-you-afford-it-real-world-web-performance-budgets/#js-is-your-most-expensive-asset" rel="noopener noreferrer"&gt;real world network and device-capability factors&lt;/a&gt;, performance starts with &lt;em&gt;shipping less bytes&lt;/em&gt;, especially when it coms to JavaScript - &lt;a href="https://infrequently.org/2017/10/can-you-afford-it-real-world-web-performance-budgets/#js-is-your-most-expensive-asset" rel="noopener noreferrer"&gt;your most expensive asset&lt;/a&gt;. (Truth is, all of the extra things like instant navigations and transitions that will delight your users need your app to &lt;em&gt;first be accessible&lt;/em&gt;!)&lt;/p&gt;

&lt;p&gt;Unfortunately, SPA frameworks, who have this as their primary call, have their engineering model going the &lt;em&gt;opposite&lt;/em&gt; way: &lt;strong&gt;towards more JavaScript&lt;/strong&gt;! These may follow different programming paradigms... but all have got the same &lt;em&gt;JavaScript&lt;/em&gt; bottom-line!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[HTML, CSS, JS]&lt;/code&gt; &amp;gt; &lt;code&gt;Build_Step&lt;/code&gt; &amp;gt; &lt;code&gt;[JS, JS, JS]&lt;/code&gt; e.g. Svelte, Vue &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[JS, JS, JS]&lt;/code&gt; &amp;gt; &lt;code&gt;Build_Step&lt;/code&gt; &amp;gt; &lt;code&gt;[JS, JS, JS]&lt;/code&gt; e.g. React&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Your final bundle here is the sum of your &lt;em&gt;framework&lt;/em&gt; bundle, plus your &lt;em&gt;essential&lt;/em&gt; JS, plus the &lt;em&gt;induced&lt;/em&gt; (usually larger) JS from page structure, content, and styling - the obvious math to Frontend's &lt;a href="https://httparchive.org/reports/page-weight#bytesJs" rel="noopener noreferrer"&gt;terrifying payloads&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With your application's entire weight now culminating in JavaScript... and its non-JS aspects - page structure, content, and styling - now being accounted for in JS, you're now wrongly set up for the real world! It soon becomes clear how much of a knife edge you're on as your application becomes a real thing and starts to regress with every weight gained!&lt;/p&gt;

&lt;p&gt;Not surprising... the idea of a "highly-optimized", "accessible", "functional" application quickly falls apart!&lt;/p&gt;

&lt;p&gt;Reporting on this in the 2017 Real-world Web Performance Budgets (here), Alex Russell &lt;a href="https://infrequently.org/2017/10/can-you-afford-it-real-world-web-performance-budgets/#:~:text=i%27ve%20seen%20teams%20that%20have,%20faster%22%20experiences%20under%20real-world%20conditions." rel="noopener noreferrer"&gt;relates&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I've seen teams that have just finished re-building on a modern tech stack cringe for an hour as we walk them through the experience of using their 'better', 'faster' experiences under real-world conditions."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Tim Kadlec also &lt;a href="https://timkadlec.com/remembers/2020-04-21-the-cost-of-javascript-frameworks/#:~:text=what%20is%20clear%3A%20right%20now%2C%20if%20you%E2%80%99re%20using%20a%20framework,in%20the%20best%20of%20scenarios.&amp;amp;text=if%20you%20are%20going%20to%20use%20one%20of%20these%20frameworks,meantime." rel="noopener noreferrer"&gt;notes from field experience&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"What is clear: right now, if you’re using a framework to build your site, you’re making a trade-off in terms of initial performance—even in the best of scenarios. [...] If you are going to use one of these frameworks, then you have to take extra steps to make sure you don’t negatively impact performance in the meantime."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is often excluded in the conversation, but many are winding up with more tooling-induced performance problems than they ever would otherwise! How entirely counterproductive!&lt;/p&gt;

&lt;h3&gt;
  
  
  ...on the &lt;em&gt;developer&lt;/em&gt; front
&lt;/h3&gt;

&lt;p&gt;Performance is all about being able to tame complexity with the least amount of overhead. This calls for the abstractions/tools for managing complexity to hold to "a 'first do no harm' principle... make sure you are at least no less productive with overhead than you were without it." (&lt;a href="https://dev.to/swyx/what-drives-optimal-overhead-2p3a#:~:text=a%20%22first%20do%20no%20harm%22,without%20it."&gt;Swyx&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Question is: are we really improving at managing complexity? Not when it feels like we're drowning in &lt;strong&gt;more complexity than ever&lt;/strong&gt;, with an entire curriculum of &lt;a href="https://auth0.com/blog/glossary-of-modern-javascript-concepts/" rel="noopener noreferrer"&gt;deep programming concepts&lt;/a&gt; taking the place of what used to be the "HTML" kind of problems, and along with that a doze of &lt;a href="https://dev.to/this-is-learning/a-look-at-compilation-in-javascript-frameworks-3caj"&gt;compilers&lt;/a&gt; - that themselves have to cater to a number of new paradigms, magic syntaxes and dialects!&lt;/p&gt;

&lt;p&gt;We must now rigor through the surprisingly high amount of &lt;em&gt;code-level complexity&lt;/em&gt;, and pay the price of a &lt;em&gt;compile-step&lt;/em&gt; (with &lt;a href="https://webpack.js.org/" rel="noopener noreferrer"&gt;Webpack&lt;/a&gt; and &lt;a href="https://babeljs.io/" rel="noopener noreferrer"&gt;babel&lt;/a&gt; (or similar beast) and a barrage of configurations, plugins and extensions) to have a working web page! But that's not all, we must also bend along with mind-bending &lt;em&gt;runtime behaviours&lt;/em&gt; (of hooks and friends), and &lt;em&gt;debug&lt;/em&gt; through difficult-to-grok transforms of our code!&lt;/p&gt;

&lt;p&gt;At this point... you're now entirely cracking a different grade of nut! Everything easy is hard again&lt;sup id="fnref1"&gt;1&lt;/sup&gt;!&lt;/p&gt;

&lt;p&gt;Jelan &lt;a href="https://news.ycombinator.com/item?id=33134021#:~:text=I%20have%20a,this%20space%20now." rel="noopener noreferrer"&gt;shares her frustration&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I'm getting more and more frustrated with all the added layers of complexity needed to work with most common frontend frameworks. I’ve hit a point where it just doesn’t seem like the end justifies the means in the vast majority of cases anymore."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And Chris Coyer &lt;a href="https://css-tricks.com/the-great-divide/#:~:text=ironically,cougar%20problem." rel="noopener noreferrer"&gt;puts a fitting analogy to that&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Ironically, while heaps of tooling add complexity, the reason they are used is for battling complexity. Sometimes it feels like releasing cougars into the forest to handle your snake problem. Now you have a cougar problem."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Look what was going to land you in the pit of success&lt;sup id="fnref2"&gt;2&lt;/sup&gt; winding you up with &lt;strong&gt;more complexity than you had at first&lt;/strong&gt;! (On the &lt;a href="https://en.wikipedia.org/wiki/No_Silver_Bullet" rel="noopener noreferrer"&gt;essential/accidental&lt;/a&gt;&lt;sup id="fnref3"&gt;3&lt;/sup&gt; scale, that's you having your "accidental" (tooling-induced) complexity trump your "essential" (real problem-space) complexity!) And again, that's utterly counterproductive!&lt;/p&gt;




&lt;p&gt;If there's anything that's obvious, it is the one thing that ruins the experience each time: &lt;strong&gt;that "JavaScript"&lt;/strong&gt;; this time, not the "JS" in the conventional "HTML, CSS, JS" approach, but the "JS" in our new "all-JS" equations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the "&lt;em&gt;all-JS&lt;/em&gt; bottom-line" engineering model - which brings all of page structure, content, and styling to JS (&lt;code&gt;Build_Step =&amp;gt; [JS, JS, JS]&lt;/code&gt;)!&lt;/li&gt;
&lt;li&gt;the "&lt;em&gt;all-JS&lt;/em&gt; front-line" engineering model - which defaults to JS for authoring page structure, content, and styling (&lt;code&gt;[JS, JS, JS] =&amp;gt; Build_Step&lt;/code&gt;)!&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Looking Back: The Paradigm Shift!
&lt;/h2&gt;

&lt;p&gt;Signaled by React's &lt;a href="https://www.youtube.com/watch?v=x7cQ3mrcKaY" rel="noopener noreferrer"&gt;Rethinking Best Practices&lt;/a&gt; pitch back in March 2013, frontend's new era has for the most part sat on what seems to be a universal axiom: &lt;strong&gt;the traditional web is awful; abstract it&lt;/strong&gt;! Everything "traditional" about the web application story - from authoring to runtime - has since been doomed for &lt;em&gt;an abstraction&lt;/em&gt; or &lt;em&gt;a re-engineering&lt;/em&gt; - with the conventional "HTML, CSS, JS" and the DOM being the first casualty of war, and JavaScript being the new default instinct!&lt;/p&gt;

&lt;p&gt;Whole new ecosystems of breakaway technologies have spun, each staying at a false dichotomy with web fundamentals and staying defensive about that! Here's for an insight into the thought process...&lt;/p&gt;

&lt;p&gt;from HTML to JavaScript:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mike Turley (on JSX): &lt;a href="https://css-tricks.com/why-javascript-is-eating-html/" rel="noopener noreferrer"&gt;Why JavaScript is Eating HTML&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Mark Dalgleish (on CSS-in-JS): &lt;a href="https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660" rel="noopener noreferrer"&gt;A Unified Styling Language&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;from the web platform to abstractions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rich Harris: &lt;a href="https://dev.to/richharris/why-i-don-t-use-web-components-2cia"&gt;Why I don't use web components&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Ryan Carniato: &lt;a href="https://dev.to/ryansolid/maybe-web-components-are-not-the-future-hfh"&gt;Maybe Web Components are not the Future?&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ...from HTML to JavaScript
&lt;/h3&gt;

&lt;p&gt;A surprising exodus ensues!&lt;/p&gt;

&lt;p&gt;"HTML has been the running punchline in the web development community lately. [...] We are in the midst of a very large problem in the web development field, where HTML is being left in the rearview mirror in place of JavaScript", &lt;a href="https://www.deque.com/blog/javascript-frameworks-the-lost-art-of-html/#:~:text=HTML%20has%20been%20the%20running%20punchline%20in%20the%20web%20development%20community%20lately.&amp;amp;text=We%20are%20in%20the%20midst%20of%20a%20very%20large%20problem,JavaScript." rel="noopener noreferrer"&gt;writes Mark Steadman&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;React's infamous movement may have had an initial context of just &lt;a href="https://en.wikipedia.org/wiki/JSX_(JavaScript)" rel="noopener noreferrer"&gt;JSX&lt;/a&gt; and, later, &lt;a href="https://en.wikipedia.org/wiki/CSS-in-JS" rel="noopener noreferrer"&gt;CSS-in-JS&lt;/a&gt;! But unfortunately, this has swept and overturned how a broader share of the frontend tooling space thinks! There's now multiple JS-first agendas everywhere you look - even on web platform proposal boards!&lt;/p&gt;

&lt;p&gt;Consider as honorable mentions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md" rel="noopener noreferrer"&gt;HTML Modules&lt;/a&gt; - a proposed "JS-first" &lt;em&gt;import&lt;/em&gt; mechanism for "HTML".&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/css-modules/css-modules" rel="noopener noreferrer"&gt;CSS Modules&lt;/a&gt; - a "JS-first" &lt;em&gt;import&lt;/em&gt; mechanism for "CSS".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Slowly, some of what belongs in the HTML problem space are now beginning to land as JavaScript feature proposals - sometimes downright namesquatting HTML!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But lest you asked how "HTML Modules" and friends don't solve a problem: maybe they do! But those would certainly not be the "HTML" kind of problems, but the "accidental limitation" type of problem in the JS-first world! Proposals like this are only symptomatic of having gone the "unconventional" way; you must endlessly build JS-first bridges, seek a JavaScript metaphor for every other HTML/CSS thing, and wish the rest of the web were colored &lt;a href="https://en.wikipedia.org/wiki/File:Unofficial_JavaScript_logo_2.svg" rel="noopener noreferrer"&gt;yellow&lt;/a&gt;! (You can tell clearly how these aren't a feature, but a means to an end!) And notice how this comes even at the risk of &lt;em&gt;tight-coupling&lt;/em&gt; a supposed &lt;em&gt;general-purpose&lt;/em&gt;, &lt;em&gt;DOM-agnostic&lt;/em&gt; programming language with the DOM! (See how HTML Modules in principle tortures the JavaScript language to produce DOM primitives!)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It has turned out to be not just more JavaScript being smuggled in through the back door, but also more HTML and CSS being thrown out the window! (Probably the greater harm!) Think the case regarding the removal - rather than improvement - of &lt;a href="https://web.dev/imports/" rel="noopener noreferrer"&gt;HTML Imports&lt;/a&gt; from the spec in favour of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules" rel="noopener noreferrer"&gt;ES6 Modules&lt;/a&gt; - or possibly now the name-squatting HTML Modules above! It just happened that "the JS-centric zeitgeist won" this over - to put it in &lt;a href="https://bradfrost.com/blog/link/why-were-breaking-up-with-css-in-js/#:~:text=the%20js-centric%20zeitgeist%20version%20won%2C%20which%20is%20why%20we%20don%E2%80%99t%20have%20html%20imports" rel="noopener noreferrer"&gt;Brad Frost's words&lt;/a&gt;!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;And is someone pointing to the removal of Scoped CSS in favour of Shadow DOM based CSS? We'll come to that!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;JS-first has this way led to setting fire on many good thinking around HTML just to have them reborn in JavaScript! An irreversible, all-in proposition!&lt;/p&gt;

&lt;p&gt;Needles to say is how therefore many highly-missing features in HTML aren't even in the radar on proposal boards! When you look around, really, how much "developer mind-share" does HTML have anymore to push those?&lt;/p&gt;

&lt;p&gt;This has been so deep that if you dared to contend with the status quo and build a specialised career on real UI development skills that means less engineering, you'd find yourself in the marginalised half of the &lt;a href="https://css-tricks.com/the-great-divide/" rel="noopener noreferrer"&gt;Great Divide&lt;/a&gt; and &lt;a href="https://news.ycombinator.com/item?id=33134021#:~:text=the%20one%20redeeming%20quality%20of%20doing%20this%20kind%20of%20work%20is%20that%20it%20is%20in%20very%20high%20demand%2C%20and%20i%20worry%20that%20the%20price%20of%20becoming%20more%20specialized%20or%20doing%20something%20more%20enjoyable%20with%20less%20bloat%20is%20that%20it%20becomes%20much%20harder%20to%20find%20jobs." rel="noopener noreferrer"&gt;risk not having a career&lt;/a&gt;! (So then, &lt;a href="https://bradfrost.com/blog/link/why-were-breaking-up-with-css-in-js/#:~:text=Again%20we%E2%80%99re%20all,and%20learned%20React." rel="noopener noreferrer"&gt;many devs have had to acquiesce against their own will&lt;/a&gt; considering that there are bills to pay!)&lt;/p&gt;

&lt;h3&gt;
  
  
  ...from the web platform to abstractions
&lt;/h3&gt;

&lt;p&gt;Suddenly, the platform is abandoned!&lt;/p&gt;

&lt;p&gt;Born out of contempt and mischaracterization of the web platform, the focus of modern abstractions has come to seem somewhat like &lt;em&gt;re-engineering&lt;/em&gt; web languages, &lt;em&gt;replicating&lt;/em&gt; platform features and APIs, and &lt;em&gt;duplicating&lt;/em&gt; the browser's efforts! The whole idea of using the web platform has remained an unattractive option for breakaway technologies. To put it in &lt;a href="https://infrequently.org/2017/10/web-components-the-long-game/#:~:text=the%20incentives%20of%20framework%20authors%20are%20not%20aligned%20with%20compatibility" rel="noopener noreferrer"&gt;Alex Russell's words&lt;/a&gt;, "The incentives of framework authors are not aligned with compatibility". I often see "web standards" being touted only where it makes a big news or where the performance gains are the incentive!&lt;/p&gt;

&lt;p&gt;Looking back at how React and its ecosystem has stayed detached over the years, Mikeal Rogers relates:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"I remember when React was launched, the whole thing was about DOM diffing. The value of it is this virtual DOM thing. Then we made the DOM fast, and who gives a shit now. But we’re still using React because of – I don’t know. [...] And then now we have Web Components and they can’t adopt it, because they’re on their own pattern, so we can’t take this feature upgrade from the platform. [And] I think there's a ton of other examples of this where the platform starts to catch up, and then the frameworks can’t."&lt;/em&gt; - &lt;a href="https://changelog.com/jsparty/89#:~:text=i%20remember%20when%20react%20was%20launched%2C%20the%20whole%20thing%20was%20about%20dom%20diffing,we%E2%80%99re%20still%20using%20react%20because%20of%20%E2%80%93%20i%20don%E2%80%99t%20know&amp;amp;text=and%20then%20now%20we%20have%20web%20components%20and%20they%20can%E2%80%99t%20adopt%20it,platform%20starts%20to%20catch%20up%2C%20and%20then%20the%20frameworks%20can%E2%80%99t." rel="noopener noreferrer"&gt;JS Party – Episode #89 | Changelog&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We just seem to be disposed to trading the "norm" and yet searching for the "kind" in the &lt;em&gt;abstract&lt;/em&gt; world!&lt;/p&gt;

&lt;p&gt;And what has been a particularly sad implication of the framework-first culture? The more we've invested in breakaway technologies and side ecosystems, &lt;em&gt;the less we've learned about our real problem space and all the opportunities to actually move the web forward&lt;/em&gt;! It turns out, HTML and its ecosystem remains &lt;em&gt;undertooled&lt;/em&gt; to date, whereas the framework web continues to flourish! You're now almost guaranteed to get stranded as being in a desert land building anything in vanilla HTML and the DOM:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"It’s really depressing that most useful tools these day are made for React projects and/or require React knowledge to set up and use. This locks out many of us who are not using React for everything &amp;amp; who still prefer the vanilla route for their projects."&lt;/em&gt; - &lt;a href="https://twitter.com/sarasoueidan/status/1098960689455075330?s=21" rel="noopener noreferrer"&gt;Sara Soueidan&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You just realise how much everyone seems to have disconnected from the real "problem-space" type of problems and gotten buried in "abstract" problems, leaving us with framework-specific solutions to very common problems!&lt;/p&gt;

&lt;p&gt;It turns out, undertooling remains a real deterrent for everyone who has craved the simplicity of the vanilla web. (And this should also be one valid challenge to the &lt;em&gt;challenge&lt;/em&gt; thrown here by Remy Sharp when he asked: &lt;a href="https://remysharp.com/2021/02/11/the-web-didnt-change-you-did#:~:text=dear%20reader%20-%20let%20me%20ask%20you%20this%2C%20and%20i%20hope%20you%20ask%20your%20colleagues%20the%20same%3A%20what%27s%20stopping%20you%20from%20using%20exactly%20method%20today%3F" rel="noopener noreferrer"&gt;what's stopping you from using &lt;em&gt;exactly&lt;/em&gt; [that] method today?&lt;/a&gt;)&lt;/p&gt;




&lt;p&gt;With so much having gone wrong in the tooling space, what follows is only expected: a community at large suffering a terrible blind spot for web fundamentals! Ground truths are now debated everywhere, "best practices" are literally going numb (hi Pete), and standards are increasingly losing their place among developers! (Consider a survey: &lt;a href="https://www.smashingmagazine.com/2019/01/web-standards-guide/#why-am-i-telling-you-this" rel="noopener noreferrer"&gt;What do you know about Web Standards?&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;Go see a typical framework-speaking dev - even in their seniors of roles; go check the typical learning path of the coming generation; and go see what the modern Frontend job descriptions on job boards are saying! Surprisingly, the modern developer career is now little about web technologies themselves and all "about [the] intricacies of the most popular frameworks", to put it in &lt;a href="https://dev.to/fredericbonnet/the-third-age-of-web-development-kgj#:~:text=about%20mastering%20the%20intricacies%20of%20the%20most%20popular%20frameworks"&gt;Frédéric Bonnet's words&lt;/a&gt;! See that?&lt;/p&gt;

&lt;p&gt;There's a destructive &lt;em&gt;information gap&lt;/em&gt; and a &lt;em&gt;culture erosion&lt;/em&gt;&lt;sup id="fnref4"&gt;4&lt;/sup&gt; now also overtaking us! &lt;/p&gt;

&lt;p&gt;Suffice to say, the past decade has been &lt;strong&gt;a life of alienation&lt;/strong&gt; from conventional wisdom, almost entirely spent &lt;em&gt;trading&lt;/em&gt; HTML - and burning our ships on the go - in an irreversible bet on &lt;em&gt;JavaScript&lt;/em&gt;; turning our backs and throwing dirt on the web platform to bank futures on abstractions! Yet, only a few are really talking about the almost irreversible proposition of this decade-long shift...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"In elevating frontend to the land of Serious Code we have not just made things incredibly over-engineered but we have also set fire to all the ladders that we used to get up here in the first place."&lt;/em&gt; - &lt;a href="https://dev.to/walaura/the-web-without-the-web-aeo#:~:text=In%20elevating%20frontend,here%20in%20the%20first%20place."&gt;Laura Buns&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Towards a Faster Web: A New Quest!
&lt;/h2&gt;

&lt;p&gt;As the ills of the Framework era become more and more palpable, the &lt;a href="https://blog.daftcode.pl/hype-driven-development-3469fc2e9b22" rel="noopener noreferrer"&gt;bells and whistles of the decade&lt;/a&gt; are losing their charms on people! Folks are now coming around on our lived reality, and many are actively going back on their life's bets in search of sanity, at the risk of bringing people with torches and pitchforks to their door!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hajime Yamasaki Vukelic: &lt;a href="https://javascript.plainenglish.io/what-got-me-writing-vanilla-js-again-2c53756c8a4c" rel="noopener noreferrer"&gt;What Got Me Writing Vanilla JavaScript again&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Sam Magura: &lt;a href="https://dev.to/srmagura/why-were-breaking-up-wiht-css-in-js-4g9b"&gt;Why We're Breaking Up with CSS-in-JS&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But what about the philosophy at the tooling layer: is it now time for a rethink? It depends on how much of a rethink you are asking of!&lt;/p&gt;

&lt;p&gt;On the one hand, folks have been hard at work with identifying and addressing inherent overheads in the current system. (But of course, not with a view to rethinking the overall JS-first philosophy!)&lt;/p&gt;

&lt;p&gt;For example, realising that the idea of shipping applications as just JavaScript wasn't working anything good on the user front, React and friends have since slid back to the idea of being able to send HTML over the network. This has called for major architectural rework (think &lt;a href="https://reactjs.org/blog/2022/03/29/react-v18.html#new-suspense-features" rel="noopener noreferrer"&gt;React 18's Streaming SSR architecture&lt;/a&gt;); this being in addition to the existing idea of static site generation with build tools like &lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;Gatsby&lt;/a&gt;. Server-Side Rendering (&lt;a href="https://web.dev/rendering-on-the-web/" rel="noopener noreferrer"&gt;SSR&lt;/a&gt;) and Static Site Generation (&lt;a href="https://web.dev/rendering-on-the-web/" rel="noopener noreferrer"&gt;SSG&lt;/a&gt;) have been such a feat for the status quo!&lt;/p&gt;

&lt;p&gt;So, right now, HTML and progressive enhancement have again become an attractive option to what has been the "all-JS or nothing" camp. (In fact, &lt;a href="https://remix.run" rel="noopener noreferrer"&gt;Remix&lt;/a&gt; has this as a new bragging right! In its own words: who knew?) Put together, all of the new takes here just represent a new game plan: a long walk back to the basics; a bit of a &lt;em&gt;compromise&lt;/em&gt; on its initial takes, but a bit of some greater good: towards a faster, functional Frontend!&lt;/p&gt;

&lt;p&gt;On the other hand, a new wave of innovation is taking center stage with a more ambitious take than the ongoing long, painful walk back to the basics: this time, the idea of an outright HTML-first, "progressive enhancement" architecture from start! (SitePen Engineering gives the perfect &lt;a href="https://www.sitepen.com/blog/intro-to-html-first-frontend-frameworks" rel="noopener noreferrer"&gt;Intro to HTML-first Frontend Frameworks&lt;/a&gt; featuring &lt;a href="https://qwik.builder.io/" rel="noopener noreferrer"&gt;Qwik&lt;/a&gt;, &lt;a href="https://markojs.com/" rel="noopener noreferrer"&gt;Marko&lt;/a&gt;, &lt;a href="https://astro.build/" rel="noopener noreferrer"&gt;Astro&lt;/a&gt;, &lt;a href="https://www.11ty.dev/" rel="noopener noreferrer"&gt;11ty&lt;/a&gt;, &lt;a href="https://fresh.deno.dev/" rel="noopener noreferrer"&gt;Fresh&lt;/a&gt;, and &lt;a href="https://enhance.dev/" rel="noopener noreferrer"&gt;Enhance&lt;/a&gt;; and this is absolutely worth your time!)&lt;/p&gt;

&lt;p&gt;I find this especially interesting because, finally, everyone can see that the idea of a faster web didn't have to be the hard, compute-intensive, and yet elusive thing we've had for years! It is now clearer than ever how much of an absolute illusion we've been on... in staying &lt;em&gt;fixated to JS&lt;/em&gt; and yet &lt;em&gt;subscribed to HTML&lt;/em&gt;, albeit cleverly! You'd also realise: HTML over the network didn't have to be any "modern" wisdom or such a big deal of an innovation, or any feat! Not when this is something the web has had from genesis! (Streaming SSR from day 1 of PHP, anyone?)&lt;/p&gt;

&lt;p&gt;Sad that we seem to only live after the fact when it comes to tooling, but thanks to the new wave of frameworks for shedding the light that openly challenges the status quo! Finally, we've come to a point that we can be hopeful about: the prospect of having "accessible", "functional" applications at half the price! (Hopefully related is how we've now for the first time - since the JS-making epoch - &lt;a href="https://almanac.httparchive.org/en/2022/javascript#:~:text=from%202021%20to%202022%2C%20an%20increase%20of%208%25%20for%20mobile%20devices%20was%20observed%2C%20whereas%20desktop%20devices%20saw%20an%20increase%20of%2010%25.&amp;amp;text=is%20less%20steep%20than%20in%20previous%20years" rel="noopener noreferrer"&gt;recorded a less steep increase&lt;/a&gt; in the amount of JavaScript shipped to users!) &lt;/p&gt;




&lt;p&gt;So are we good now? Well, not just yet!&lt;/p&gt;

&lt;p&gt;Not when it seems that we've come only halfway with the idea: sending pages as HTML but authoring them as JS; addressing the tradeoff problem and its overheads on the &lt;em&gt;user&lt;/em&gt; front but leaving it unchanged on the &lt;em&gt;developer&lt;/em&gt; front! Clear yet? &lt;strong&gt;&lt;em&gt;Much&lt;/em&gt; of the "HTML" in our new HTML-first equations is still the &lt;em&gt;tooling-yielded HTML&lt;/em&gt;, not the &lt;em&gt;hand-authored HTML&lt;/em&gt;&lt;/strong&gt;; same as before where HTML is treated as a &lt;em&gt;compile target&lt;/em&gt;, an &lt;em&gt;implementation detail&lt;/em&gt;... something you'd abstract to have a good DX! "Tooling" still remains Frontend's primary means to its "HTML" end!&lt;/p&gt;

&lt;p&gt;This sheer idea of getting "HTML" behind a compile wall in favor of an abstraction is also where it begins to tell that we might yet be suffering the decade-long blindspot for the platform in a new way - &lt;strong&gt;embracing HTML for just the  performance incentives and not for the whole idea of &lt;em&gt;using the platform&lt;/em&gt;&lt;/strong&gt;! Let's just throw it out there: Frontend still isn't aligned with &lt;em&gt;using the platform&lt;/em&gt; to &lt;a href="https://developer.chrome.com/blog/modulepreload/#:~:text=giving%20bundlers%20their%20well-earned%20rest" rel="noopener noreferrer"&gt;give legacy tooling their well-earned rest&lt;/a&gt; and &lt;a href="https://world.hey.com/dhh/modern-web-apps-without-javascript-bundling-or-transpiling-a20f2755#:~:text=we're%20way%20overdue%20a%20correction%20back%20to%20simplicity%20for%20the%20frontend." rel="noopener noreferrer"&gt;take a correction back to simplicity&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/chadfowler/status/646624348028190720" rel="noopener noreferrer"&gt;Chad Fowler notes&lt;/a&gt; how deep-seated this is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"The older I get, the more I realize the biggest problem to solve in tech is to get people to stop making things harder than they have to be."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, how about just taking the plunge... and embracing the whole web platform thing? Now, we would not only be unlocking performance on both the &lt;em&gt;user&lt;/em&gt; front and the &lt;em&gt;developer&lt;/em&gt; front, we would be doing more: &lt;strong&gt;unleashing the web's full potential&lt;/strong&gt;! (And what could be a more ambitious goal?)&lt;/p&gt;

&lt;p&gt;Actually, &lt;strong&gt;this is why we're here&lt;/strong&gt;! Can we skip to the good parts?&lt;/p&gt;




&lt;h2&gt;
  
  
  Introducing: Web-Native Development!
&lt;/h2&gt;

&lt;p&gt;Take this as not the name of a new framework or some anti-framework movement, but as a playbook to unleashing the web's full potential.&lt;/p&gt;

&lt;p&gt;Web-native development&lt;sup id="fnref5"&gt;5&lt;/sup&gt; is an approach to web development that sees the web platform as an enabler in the whole application story, and in fact, a fundamental key to succeeding at each phase of that story - from authoring to runtime! This comes as a hard reset to the decade-long cultural shift and its pessimistic take on the web platform!&lt;/p&gt;

&lt;p&gt;This is really about embracing and leveraging native web technologies, APIs, languages and conventions, etc, and minimizing tooling! For a fact, there comes a time in life when this is all you really want... get things done with less of the drama! "I've been in enough teams in my 20 years of programming to value this part almost more than anything else", &lt;a href="https://dev.to/richharris/why-i-don-t-use-web-components-2cia#:~:text=i've%20been%20in%20enough%20teams%20in%20my%2020%20years%20of%20programming%20to%20value%20this%20part%20almost%20more%20than%20anything%20else."&gt;writes Andrea Giammarchi&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;As the platform and its technologies and languages advance, we often can find multiple opportunities "to shed a lot of this tooling" and defer to native approaches. (&lt;a href="https://changelog.com/jsparty/89#:~:text=and%20as%20the%20platform%20improves,%20we%20need%20to%20be%20able%20to%20shed%20a%20lot%20of%20this%20tooling." rel="noopener noreferrer"&gt;JS Party - Episode #89 | Changelog&lt;/a&gt;) Good to know is that tools are only as good as being solutions to &lt;em&gt;unsolved&lt;/em&gt; problems, not &lt;em&gt;solved&lt;/em&gt; problems! Anything in exception soon begins to change the narrative to something counterproductive! Thus, for all we've bet on custom tooling, we must now beat that Sunk Cost fallacy&lt;sup id="fnref6"&gt;6&lt;/sup&gt; to explore what's natively available!&lt;/p&gt;

&lt;p&gt;At the end of the day, web-native development &lt;strong&gt;gets you banking more on the web platform and less on abstractions&lt;/strong&gt;! You're now on the &lt;em&gt;winning&lt;/em&gt; side - rather than on the &lt;em&gt;contending&lt;/em&gt; side - of the web's "moving" story! You're now winning as the platform unfolds!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/richharris/why-i-don-t-use-web-components-2cia#:~:text=It%20should%20be,user-friendly%20interfaces."&gt;George Katsanos explains&lt;/a&gt; how this allows us take back more brain cycles to finally go make something:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"It should be obvious to all of us that if we would focus all our efforts in the Platform and stop reinventing the wheel [...] we would have a lot more free time to focus on the real reason we are in this job which is to deliver fast, stable, secure, user-friendly interfaces."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, where's a good place to get well-rounded with the web platform? Chrome's &lt;a href="https://web.dev/" rel="noopener noreferrer"&gt;web.dev&lt;/a&gt; developer centre is a treasure trove of resources on key web design and development subjects, maintained by the Chrome team and other industry experts! (&lt;a href="https://web.dev/learn/" rel="noopener noreferrer"&gt;Here's the learning centre&lt;/a&gt;.) And for when you need to take the web platform by its individual technologies, here is &lt;a href="https://developer.mozilla.org/" rel="noopener noreferrer"&gt;MDN&lt;/a&gt;! (And &lt;a href="https://developer.mozilla.org/en-US/docs/Learn" rel="noopener noreferrer"&gt;here's the learning centre&lt;/a&gt;.) For showcases, here is one: &lt;a href="https://elisehe.in/2021/08/22/using-the-platform" rel="noopener noreferrer"&gt;Using the platform&lt;/a&gt; - a delightful piece of a story on going buildless with ES6 modules and going framework-free with Web components, written by Elise Hein!&lt;/p&gt;

&lt;p&gt;Up next is: &lt;strong&gt;how far does this go in real life&lt;/strong&gt;? Build a twitter clone with zero tooling? Uhh, that has never been the idea, and we may never get there! The web platform is anything but a framework of its own! &lt;em&gt;At some point&lt;/em&gt;, we are going to have to need higher-level abstractions over native lower-level features! Where there seems to be a bit of a bad news is that &lt;strong&gt;the current state of HTML and the DOM makes that happen &lt;em&gt;sooner&lt;/em&gt;&lt;/strong&gt;; it isn't long into the journey before gaps and dips in the platform gets you into forced labour! But we can easily turn this around by investing along two lines:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Low-level tooling&lt;/strong&gt;: platform-focused initiative to &lt;em&gt;standardise&lt;/em&gt; and &lt;em&gt;factor into the platform&lt;/em&gt; common web development architectures and paradigms. (We're overdue for native-level reactivity and a more empowering component model - just to mention a few!)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Higher-level tooling&lt;/strong&gt;: community-focused initiative to &lt;em&gt;extend&lt;/em&gt; the platform's low-level capabilities with "web-native" libraries and frameworks. (We need a new wave of modest abstractions that draw on the web platform and let us do the same!)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;This is where I &lt;em&gt;put my money where my mouth is&lt;/em&gt;!&lt;/strong&gt; I'd like to take you on a few ideas I've been working on along these lines!&lt;/p&gt;

&lt;p&gt;Open to some tooling ideas?&lt;/p&gt;

&lt;h3&gt;
  
  
  Explore with Me...
&lt;/h3&gt;

&lt;p&gt;Our journey spans a series of posts! We begin with the underlying equations and move on to a showcase of the proposals and polyfils, the userland libraries and framework!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For the curious, &lt;a href="https://github.com/webqit/webqit" rel="noopener noreferrer"&gt;here's a sneak peak&lt;/a&gt; into this project on github.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No frameworks were harmed in the creation of this article.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Acknowledgements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Special thanks to &lt;a href="https://infrequently.org" rel="noopener noreferrer"&gt;Alex Russell&lt;/a&gt; for the time spent reviewing this article!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://infrequently.org/2017/10/can-you-afford-it-real-world-web-performance-budgets/" rel="noopener noreferrer"&gt;Can You Afford It?: Real-world Web Performance Budgets&lt;/a&gt; (Alex Russell)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://httparchive.org/reports/page-weight#bytesJs" rel="noopener noreferrer"&gt;2022 Page Weight Report: JavaScript Bytes&lt;/a&gt; (HTTP Archive)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://timkadlec.com/remembers/2020-04-21-the-cost-of-javascript-frameworks/" rel="noopener noreferrer"&gt;The Cost of JavaScript Frameworks&lt;/a&gt; (Tim Kadlec)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/swyx/what-drives-optimal-overhead-2p3a"&gt;What drives Optimal Overhead?&lt;/a&gt; (Shawn Wang)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://auth0.com/blog/glossary-of-modern-javascript-concepts/" rel="noopener noreferrer"&gt;Glossary of Modern JavaScript Concepts: Part 1&lt;/a&gt; (Kim Maida)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.youtube.com/watch?v=x7cQ3mrcKaY" rel="noopener noreferrer"&gt;Rethinking Best Practices&lt;/a&gt; (Pete Hunt)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://css-tricks.com/why-javascript-is-eating-html/" rel="noopener noreferrer"&gt;Why JavaScript is Eating HTML&lt;/a&gt; (Mike Turley)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/seek-blog/a-unified-styling-language-d0c208de2660" rel="noopener noreferrer"&gt;A Unified Styling Language&lt;/a&gt; (Mark Dalgleish)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/richharris/why-i-don-t-use-web-components-2cia"&gt;Why I don't use web components&lt;/a&gt; (Rich Harris)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/ryansolid/maybe-web-components-are-not-the-future-hfh"&gt;Maybe Web Components are not the Future?&lt;/a&gt; (Ryan Carniato)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.deque.com/blog/javascript-frameworks-the-lost-art-of-html/" rel="noopener noreferrer"&gt;JavaScript Frameworks &amp;amp; The Lost Art of HTML&lt;/a&gt; (Mark Steadman)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bradfrost.com/blog/link/why-were-breaking-up-with-css-in-js/" rel="noopener noreferrer"&gt;why we’re breaking up with css-in-js&lt;/a&gt; (Brad Frost)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://css-tricks.com/the-great-divide/" rel="noopener noreferrer"&gt;The Great Divide&lt;/a&gt; (Chris Coyer)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://infrequently.org/2017/10/web-components-the-long-game/" rel="noopener noreferrer"&gt;Web Components: The Long Game&lt;/a&gt; (Alex Russell)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://changelog.com/jsparty/89" rel="noopener noreferrer"&gt;Is modern JS tooling too complicated?&lt;/a&gt; (JS Party – Episode #89 | Changelog)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://remysharp.com/2021/02/11/the-web-didnt-change-you-did" rel="noopener noreferrer"&gt;The web didn't change; you did&lt;/a&gt; (Remy Sharp)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.smashingmagazine.com/2019/01/web-standards-guide/" rel="noopener noreferrer"&gt;Web Standards: The What, The Why, And The How&lt;/a&gt; (Amy Dickens)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/fredericbonnet/series/10459"&gt;From Classicism to Metamodernism — A Short History of Web Development Series' Articles&lt;/a&gt; (Frédéric Bonnet)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blog.daftcode.pl/hype-driven-development-3469fc2e9b22" rel="noopener noreferrer"&gt;Hype Driven Development&lt;/a&gt; (Marek Kirejczyk)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://javascript.plainenglish.io/what-got-me-writing-vanilla-js-again-2c53756c8a4c" rel="noopener noreferrer"&gt;What Got Me Writing Vanilla JavaScript again&lt;/a&gt; (Hajime Yamasaki Vukelic)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/srmagura/why-were-breaking-up-wiht-css-in-js-4g9b"&gt;Why We're Breaking Up with CSS-in-JS&lt;/a&gt; (Sam Magura)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.sitepen.com/blog/intro-to-html-first-frontend-frameworks" rel="noopener noreferrer"&gt;Intro to HTML-first Frontend Frameworks&lt;/a&gt; (SitePen Engineering)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://world.hey.com/dhh/modern-web-apps-without-javascript-bundling-or-transpiling-a20f2755" rel="noopener noreferrer"&gt;Modern web apps without JavaScript bundling or transpiling&lt;/a&gt; (David Heinemeier Hansson)&lt;/li&gt;
&lt;/ul&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;Borrowing Frank Chimero's title: &lt;a href="https://frankchimero.com/blog/2018/everything-easy/" rel="noopener noreferrer"&gt;Everything Easy is Hard Again&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn2"&gt;
&lt;p&gt;Defining &lt;a href="https://english.stackexchange.com/questions/77535/what-does-falling-into-the-pit-of-success-mean" rel="noopener noreferrer"&gt;The Pit of Success&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn3"&gt;
&lt;p&gt;See &lt;a href="http://worrydream.com/refs/Brooks-NoSilverBullet.pdf" rel="noopener noreferrer"&gt;Fred Brooks: No Silver Bullet (PDF)&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn4"&gt;
&lt;p&gt;See &lt;a href="https://geographyrevisionalevel.weebly.com/6b-cultural-erosion.html" rel="noopener noreferrer"&gt;Cultural Erosion&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;li id="fn5"&gt;
&lt;p&gt;"Web-native" is a recurring theme across multiple initiatives and paradigms: ↩&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://webnative.tech" rel="noopener noreferrer"&gt;Web Native&lt;/a&gt; - Ionic Team's presentation of the idea, but scoped to its &lt;a href="https://capacitorjs.com/" rel="noopener noreferrer"&gt;Capacitor&lt;/a&gt; runtime.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/fredericbonnet/the-third-age-of-web-development-kgj#:~:text=web-native"&gt;Web-Native&lt;/a&gt; - Frédéric Bonnet's presentation of the idea in &lt;a href="https://dev.to/fredericbonnet/the-third-age-of-web-development-kgj#:~:text=market%20(2012-today).-,the%20postmodernist%20period%20,-and%20the%20Second"&gt;The Postmodernist Period&lt;/a&gt; of &lt;a href="https://dev.to/fredericbonnet/the-third-age-of-web-development-kgj"&gt;The Third Age of Web Development&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://modern-web.dev" rel="noopener noreferrer"&gt;Modern Web&lt;/a&gt; - Guides, tools and libraries for modern web development built on web standards.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://tutorials.yax.com/articles/the-yax-way/index.html" rel="noopener noreferrer"&gt;The Stackless Way&lt;/a&gt; - Daniel Kehoe's optimistic take on web development that proposes we “use the platform” instead of frameworks and build tools.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://buildless.site" rel="noopener noreferrer"&gt;Buildless&lt;/a&gt; - Pascal Schilp's paradigm for creating production websites without a build process.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some related tags:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;#buildless - &lt;a href="https://dev.to/t/buildless"&gt;DEV&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;#vanilla - &lt;a href="https://dev.to/t/vanilla"&gt;DEV&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;#useThePlatform - &lt;a href="https://twitter.com/hashtag/justUseThePlatform?src=hashtag_click" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;

&lt;li id="fn6"&gt;
&lt;p&gt;See &lt;a href="https://en.wikipedia.org/wiki/Sunk_cost" rel="noopener noreferrer"&gt;Sunk Cost Fallacy&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>tooling</category>
      <category>webqit</category>
    </item>
    <item>
      <title>Reflex-Based Web Monetization API - Hackathon Submission</title>
      <dc:creator>Oxford Harrison</dc:creator>
      <pubDate>Mon, 15 Jun 2020 05:07:12 +0000</pubDate>
      <link>https://forem.com/oxharris/reflex-based-web-monetization-api-hackathon-submission-579l</link>
      <guid>https://forem.com/oxharris/reflex-based-web-monetization-api-hackathon-submission-579l</guid>
      <description>&lt;p&gt;The Web Monetization API has seen a lot of integration patterns that are tuned to many of the current frontend frameworks and developer tools. With each pattern serving only a specific community, I decided to explore a vanilla-level technology for Web Monetization for the rest of the web.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;A &lt;a href="https://docs.web-native.dev/reflex"&gt;Reflex-based&lt;/a&gt; Web Monetization API that is consumable as a &lt;strong&gt;plain&lt;/strong&gt;, but &lt;strong&gt;reactive&lt;/strong&gt; JavaScript object instead of an &lt;code&gt;EventTarget&lt;/code&gt; interface. This is a new API that promises new foundational possibilities! &lt;a href="https://dev.to/oxharris/reflex-based-web-monetization-api-5241"&gt;Here&lt;/a&gt; is my introductory DEV post to this project, where I explained key problems solved and a few use cases.&lt;/p&gt;

&lt;p&gt;To highlight, the goal of this project is to provide a &lt;strong&gt;minimalist API&lt;/strong&gt; that lets us implement web monetization with zero boiler plate.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// You initialize a WebMonetization instance with a payment pointer&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;WebMonetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$ilp.example.com/me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;That instance object will now be a joy to consume! For example, instead of the mental stress of maintaining the relationship between the standard &lt;code&gt;document.monetization.state&lt;/code&gt; property and its three state-change events (&lt;code&gt;monetizationpending&lt;/code&gt;, &lt;code&gt;monetizationstart&lt;/code&gt;, &lt;code&gt;monetizationstop&lt;/code&gt;), we would simply observe this object's &lt;code&gt;.state&lt;/code&gt; property directly.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Observe the state property live&lt;/span&gt;
&lt;span class="nx"&gt;Reflex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;state&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newState&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newState&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// pending, started, stopped&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;If we were to need dynamic start and stop of the payment stream, we wouldn't have to worry about dynamically creating and removing the appropriate &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; tag. The &lt;code&gt;monetization.start()&lt;/code&gt; and &lt;code&gt;monetization.stop()&lt;/code&gt; methods automatically take care of that.&lt;/p&gt;

&lt;p&gt;And what about tracking progress and deriving totals? The &lt;code&gt;monetization.progress&lt;/code&gt; would come into play.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Observe the progress property live&lt;/span&gt;
&lt;span class="nx"&gt;Reflex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;progress&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;progressDetails&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;progressDetails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currentTotal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Totals since calling the instance's start() method&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;progressDetails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sessionTotal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Totals since initializing the instance&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;An observable object just gives us only properties to think about - in reading their values both statically and dynamically.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The totals at any given point in time&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currentTotal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// The totals on the fly&lt;/span&gt;
&lt;span class="nx"&gt;Reflex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;progress&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;progressDetails&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currentTotal&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Now, what's even more interesting is that in real life, we can do without observing anything! Observable objects like this are the perfect subjects for the &lt;a href="https://docs.web-native.dev/chtml"&gt;ScopedJS&lt;/a&gt; technology! We can simply bind any elements to properties of these object to achieve any UI behaviour. ScopedJS's automatic observability will do the heavy-lifting of keeping everything in sync.&lt;/p&gt;

&lt;p&gt;First we would make the WebMonetization instance available to scoped scripts.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;ENV&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WebNative&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ScopedJS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;globals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And we could simply orchestrate behaviour in the document on the fly!&lt;/p&gt;

&lt;p&gt;Here is an example taken from the &lt;a href="https://dev.to/oxharris/reflex-based-web-monetization-api-5241"&gt;introductory post&lt;/a&gt; where we toggle the visibility of an exclusive section on the page by simply referencing the &lt;code&gt;monetization.state&lt;/code&gt; property.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;exclusive&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;exclusive&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;script&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text/scoped-js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;// This statement will run as a reflex action&lt;/span&gt;
          &lt;span class="c1"&gt;// to each change in monetization.state&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;started&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/script&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/body&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;And as other examples in there show, we could go to weave-in more monetization logic as part of our UI's presentational logic.&lt;/p&gt;
&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;Foundational Technology&lt;/p&gt;
&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;The &lt;em&gt;project support&lt;/em&gt; banner at &lt;a href="https://web-native.dev"&gt;web-native.dev&lt;/a&gt; featuring Web Monetization was implemented using the Reflex-based Web Monetization API.&lt;/p&gt;
&lt;h2&gt;
  
  
  Link to Code
&lt;/h2&gt;

&lt;p&gt;This API is currently primarily documented in the &lt;a href="https://dev.to/oxharris/reflex-based-web-monetization-api-5241"&gt;introductory post&lt;/a&gt;. An official documentation will be arriving soon for the entire list of &lt;a href="https://docs.web-native.dev/reflex-components"&gt;Reflex-based components&lt;/a&gt; at Web-Native.&lt;/p&gt;

&lt;p&gt;Repository: &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/web-native"&gt;
        web-native
      &lt;/a&gt; / &lt;a href="https://github.com/web-native/reflex-components"&gt;
        reflex-components
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Reflex Components&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;Application components and client-side APIs implemented as objects with observable properties.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
Documentation&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://docs.web-native.dev/reflex-components/" rel="nofollow"&gt;The Reflex Components Official Guide&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
Issues&lt;/h2&gt;
&lt;p&gt;To report bugs or request features, please submit an issue to this repository.&lt;/p&gt;
&lt;h2&gt;
License&lt;/h2&gt;
&lt;p&gt;MIT.&lt;/p&gt;
&lt;/div&gt;

  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/web-native/reflex-components"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  How I built it
&lt;/h2&gt;

&lt;p&gt;I am creating this project as part of the &lt;a href="https://web-native.dev"&gt;Web-Native project&lt;/a&gt; - a larger mission to make certain modern UI development techniques possible at platform level. With the Reflex-based monetization API now part of the Web-Native suite, we now have an all-native way to designing the UI.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write in Vanilla.&lt;/strong&gt; - Leave your markup in vanilla HTML - not even a template syntax is required. And yes! none of a framework code (&lt;code&gt;&amp;lt;IfWebMonetized&amp;gt;...&amp;lt;/IfWebMonetized&amp;gt;&lt;/code&gt;) that would look simple on the eyes but incur unnecessary tooling and engineering, and the inevitable  compile step.
And, probably one of the most important advantages with a markup-level technology, this implementation makes code more universal! It lets us integrate seamlessly with other wonderful tools that &lt;em&gt;read&lt;/em&gt; and &lt;em&gt;write&lt;/em&gt; HTML. So, instead of the lock-in with an all-JS stack, a PHP backend that &lt;em&gt;spits out&lt;/em&gt; HTML could be everything.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write your Logic.&lt;/strong&gt; - The Reflex-based monetization API is not some &lt;code&gt;&amp;lt;custom-element /&amp;gt;&lt;/code&gt; that would encapsulate only a &lt;strong&gt;predetermined behaviour&lt;/strong&gt;. It works along with the &lt;a href="https://docs.web-native.dev/chtml"&gt;ScopedJS&lt;/a&gt; foundational technology that provides platform-level capabilities for creating anything, offering more flexibility and control.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintain the Modern UI Development Pattern.&lt;/strong&gt; - We simply cannot remember a time without &lt;strong&gt;componentization&lt;/strong&gt; and &lt;strong&gt;reactivity&lt;/strong&gt; anymore! Bringing the Web Monetization API to vanilla HTML does not trade these patterns either. What we get instead is &lt;strong&gt;Web Monetization&lt;/strong&gt; plus &lt;strong&gt;componentization&lt;/strong&gt; plus &lt;strong&gt;reactivity&lt;/strong&gt; - all out of the realm of JavaScript files! (You may want to check out &lt;a href="https://docs.web-native.dev/chtml"&gt;CHTML&lt;/a&gt; for the rest of the news.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Additional Resources/Info
&lt;/h2&gt;

&lt;p&gt;The overall theme of this project is provided by the &lt;a href="https://web-native.dev"&gt;Web-Native&lt;/a&gt; project.&lt;/p&gt;

</description>
      <category>gftwhackathon</category>
      <category>webnative</category>
      <category>chtml</category>
      <category>scopedjs</category>
    </item>
    <item>
      <title>Reflex-Based Web Monetization API</title>
      <dc:creator>Oxford Harrison</dc:creator>
      <pubDate>Sat, 06 Jun 2020 04:04:11 +0000</pubDate>
      <link>https://forem.com/oxharris/reflex-based-web-monetization-api-5241</link>
      <guid>https://forem.com/oxharris/reflex-based-web-monetization-api-5241</guid>
      <description>&lt;p&gt;This is a Reflex-based (live) object that wraps the Web Monetization API. &lt;a href="https://docs.web-native.dev/reflex" rel="noopener noreferrer"&gt;Reflex&lt;/a&gt; is JavaScript's new observability API that lets us observe JavaScript objects and arrays, combining the magic of the once useful &lt;code&gt;Object.observe()&lt;/code&gt; API with other JavaScript reflection APIs - &lt;code&gt;Object&lt;/code&gt; and &lt;code&gt;Reflect&lt;/code&gt;. Making the Web Monetization API a live, observable object will be opening up new exciting ways to integrate Web Monetization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Solved
&lt;/h2&gt;

&lt;p&gt;State changes in the Web Monetization API is event-based and this leaves us much engineering work to do. For example, to track changes to the &lt;code&gt;document.monetization.state&lt;/code&gt; property, we have to remember three (3) different event names ( &lt;code&gt;monetizationpending&lt;/code&gt;, &lt;code&gt;monetizationstart&lt;/code&gt;, &lt;code&gt;monetizationstop&lt;/code&gt;) and implement three (3) different callbacks. A Reflex-based object would simply offer this property as an observable property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The initial state...&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Subsequent states would now be...&lt;/span&gt;
&lt;span class="nx"&gt;Reflex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;state&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newState&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newState&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// pending, started, stopped&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the level of simplicity led by Reflex, underpinning a growing collection of Reflex-based APIs at the &lt;a href="https://web-native.dev" rel="noopener noreferrer"&gt;Web-Native Project&lt;/a&gt;. The long-term promise of this is &lt;em&gt;reactivity&lt;/em&gt; without a framework; change-detection in vanilla JavaScript!&lt;/p&gt;

&lt;p&gt;The Web Monetization API will now also be &lt;em&gt;reflexive&lt;/em&gt; and natively playing with the rest of the Reflex-driven world.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;This library is part of the official &lt;a href="https://docs.web-native.dev/reflex-components" rel="noopener noreferrer"&gt;Reflex Components&lt;/a&gt; package.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;Money&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@web-native-js/reflex-components&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Reflex&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@web-native-js/reflex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;WebMonetization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Money&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WebMonetization&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Initialize an instance with a payment pointer&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;WebMonetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$ilp.example.com/me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Observe state&lt;/span&gt;
&lt;span class="nx"&gt;Reflex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;observe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;state&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;newState&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Code here...&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Start/stop anytime&lt;/span&gt;
&lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// monetization.stop();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Features
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Start/Stop Methods&lt;/strong&gt; - Calling the &lt;code&gt;.start()&lt;/code&gt; method would create the appropriate meta tag in the document head, if not already exists. The &lt;code&gt;.stop()&lt;/code&gt; method removes it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple Pointer Implementations&lt;/strong&gt; - Multiple instances could be initialized with different payment pointers. Calling &lt;code&gt;.start()&lt;/code&gt; on an instance starts a new payment stream and stops any currently active one.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Optional Prompt&lt;/strong&gt; - Users coming to a monetized site without a supporting browser might need to be informed of the feature. This can be specified in our call to &lt;code&gt;.init()&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;WebMonetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$ilp.example.com/me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;The prompt automatically detects the user's browser and asks to take them to the appropriate extension for their browser.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Observable Properties&lt;/strong&gt; - Now we only need to think of properties, not events and callbacks. These properties are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;state&lt;/strong&gt; - &lt;code&gt;(string)&lt;/code&gt;. This can either be &lt;code&gt;started&lt;/code&gt;, &lt;code&gt;pending&lt;/code&gt;, &lt;code&gt;stopped&lt;/code&gt;. The following three other properties also reflect the state of the instance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pending&lt;/strong&gt; - &lt;code&gt;(object|boolean)&lt;/code&gt;. This becomes an object when &lt;em&gt;state&lt;/em&gt; goes &lt;code&gt;pending&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt; otherwise. This object maps to the &lt;code&gt;event.detail&lt;/code&gt; property of the underlying &lt;code&gt;monetizationpending&lt;/code&gt; event.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;started&lt;/strong&gt; - &lt;code&gt;(object|boolean)&lt;/code&gt;. This becomes an object when &lt;em&gt;state&lt;/em&gt; turns  &lt;code&gt;started&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt; otherwise. This object maps to the &lt;code&gt;event.detail&lt;/code&gt; property of the underlying &lt;code&gt;monetizationstart&lt;/code&gt; event.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;stopped&lt;/strong&gt; - &lt;code&gt;(object|boolean)&lt;/code&gt;. This becomes an object when &lt;em&gt;state&lt;/em&gt; gets &lt;code&gt;stopped&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt; otherwise. This object maps to the &lt;code&gt;event.detail&lt;/code&gt; property of the underlying &lt;code&gt;monetizationstopped&lt;/code&gt; event.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;progress&lt;/strong&gt; - &lt;code&gt;(object)&lt;/code&gt;. This property reflects the &lt;code&gt;event.detail&lt;/code&gt; property of the underlying &lt;code&gt;monetizationprogress&lt;/code&gt; event. Each progress update also automatically updates the following other properties.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;currentTotal&lt;/strong&gt; - &lt;code&gt;(object)&lt;/code&gt;. This object represents the totals between starts and stops on the instance. It begins at zero on each call to &lt;code&gt;.start()&lt;/code&gt;. The &lt;code&gt;currentTotal.amount&lt;/code&gt; property gives the raw sum of micro payment sent during the stream, while &lt;code&gt;currentTotal.value&lt;/code&gt; gives the sum in the format of the active currency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;sessionTotal&lt;/strong&gt; - &lt;code&gt;(object)&lt;/code&gt;. This object represents the overall totals on the instance. The &lt;code&gt;sessionTotal.amount&lt;/code&gt; property gives the raw sum, while &lt;code&gt;sessionTotal.value&lt;/code&gt; gives the sum in the format of the active currency.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;currency&lt;/strong&gt; - &lt;code&gt;(string)&lt;/code&gt;. The payment currency.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Usage in ScopedJS - the Fun Part!
&lt;/h2&gt;

&lt;p&gt;Using &lt;a href="https://docs.web-native.dev/chtml/specs" rel="noopener noreferrer"&gt;ScopedJS&lt;/a&gt;, the Reflex-based, micro runtime for JavaScript, We could &lt;strong&gt;declaratively&lt;/strong&gt; create behaviour over a &lt;code&gt;WebMonetization&lt;/code&gt; instance right within an HTML markup.&lt;/p&gt;

&lt;p&gt;First we would make the &lt;code&gt;WebMonetization&lt;/code&gt; instance available to &lt;em&gt;scoped scripts&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;ENV&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WebNative&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ScopedJS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;ENV&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;globals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;monetization&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;WebMonetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$ilp.example.com/me&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we would be able to reference the &lt;code&gt;monetization&lt;/code&gt; object from any scoped script and build behaviour on the fly with any element.&lt;/p&gt;

&lt;p&gt;Below we are toggling the visibility of an exclusive section on the page by simply referencing the &lt;code&gt;monetization.state&lt;/code&gt; property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"exclusive"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        This is exclusive content!
        &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/scoped-js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;// This statement will run as a reflex action&lt;/span&gt;
          &lt;span class="c1"&gt;// to each change in monetization.state&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;started&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we can display a live total; and even implement a threshold for our exclusive content. (E.g to show more exclusive content as payment adds up.)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"exclusive"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        This exclusive content!
        ...
        And you've streamed us &lt;span class="nt"&gt;&amp;lt;span&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"total"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/span&amp;gt;&lt;/span&gt; in total.
        &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/scoped-js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;elTotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#total&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="nx"&gt;elTotal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sessionTotal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sessionTotal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hidden&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sessionTotal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We could also add a &lt;em&gt;start button&lt;/em&gt; to the page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"start"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        Show exclusive content
        &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/scoped-js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
              &lt;span class="nx"&gt;monetization&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
          &lt;span class="p"&gt;});&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Working Demo
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://web-native.dev" rel="noopener noreferrer"&gt;web-native.dev&lt;/a&gt;'s project support banner featuring Web Monetization was implemented using the Reflex-based Web Monetization API.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next for this Project
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Good documentation&lt;/li&gt;
&lt;li&gt;Bug fixes&lt;/li&gt;
&lt;li&gt;More examples&lt;/li&gt;
&lt;li&gt;More experiments&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>gftwhackathon</category>
      <category>webnative</category>
      <category>scopedjs</category>
      <category>chtml</category>
    </item>
  </channel>
</rss>
