<?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>DEV Community: Kevin Bridges</title>
    <description>The latest articles on DEV Community by Kevin Bridges (@kevinast).</description>
    <link>https://dev.to/kevinast</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%2F103655%2Ffc9970f6-276f-4cd7-a23e-2de91f9279c8.jpeg</url>
      <title>DEV Community: Kevin Bridges</title>
      <link>https://dev.to/kevinast</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevinast"/>
    <language>en</language>
    <item>
      <title>Responsive Svelte (exploring Svelte's reactivity)</title>
      <dc:creator>Kevin Bridges</dc:creator>
      <pubDate>Fri, 17 Jul 2020 16:49:03 +0000</pubDate>
      <link>https://dev.to/kevinast/responsive-svelte-exploring-svelte-s-reactivity-5cen</link>
      <guid>https://dev.to/kevinast/responsive-svelte-exploring-svelte-s-reactivity-5cen</guid>
      <description>&lt;p&gt;&lt;a href="https://svelte.dev/"&gt;Svelte&lt;/a&gt; is truly a new and revolutionary approach to web development!  It does an amazing job of automating your app's reactivity.&lt;/p&gt;

&lt;p&gt;This article is focused on uncovering some &lt;strong&gt;"behind the scene"&lt;/strong&gt; detail of &lt;strong&gt;Svelte's reactivity&lt;/strong&gt;.  We will do this from an "observer perspective" - &lt;em&gt;by visualizing Svelte's reactivity first-hand &lt;strong&gt;(right in our application)&lt;/strong&gt;&lt;/em&gt;!  There's a bit of a mystery behind some of these concepts.  We will &lt;strong&gt;delve into some lesser-known detail&lt;/strong&gt; &lt;em&gt;(that you may have not considered)&lt;/em&gt;!  The hope is you will come away with more insight, and be better informed on how to use this awesome product!&lt;/p&gt;

&lt;p&gt;This is &lt;strong&gt;not a Svelte tutorial&lt;/strong&gt;.  For the most part, any developer should be able to comprehend the concepts discussed here.  Ideally you should know the basics of Svelte.  While you won't need to be an expert, we will &lt;strong&gt;not&lt;/strong&gt; spend time explaining rudimentary Svelte constructs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A big thanks&lt;/strong&gt; to &lt;a href="https://twitter.com/mark_volkmann"&gt;Mark Volkmann&lt;/a&gt; for his review of my effort.  I am just starting my Svelte journey, so Mark's insight was invaluable!  You may want to check out his new book: &lt;a href="https://www.manning.com/books/svelte-and-sapper-in-action"&gt;Svelte and Sapper in Action&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  At a Glance
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;TL;DR&lt;/li&gt;
&lt;li&gt;Video Presentation&lt;/li&gt;
&lt;li&gt;Svelte Reactivity&lt;/li&gt;
&lt;li&gt;
Reactive Triggers

&lt;ul&gt;
&lt;li&gt;Primitive Types&lt;/li&gt;
&lt;li&gt;Object Types&lt;/li&gt;
&lt;li&gt;Staleness Summary&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Exploring App Reactivity

&lt;ul&gt;
&lt;li&gt;Diagnostic Logging Probes&lt;/li&gt;
&lt;li&gt;Advanced Diagnostics&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Demo App&lt;/li&gt;
&lt;li&gt;
Inspecting App Reactivity

&lt;ul&gt;
&lt;li&gt;Logging Probes&lt;/li&gt;
&lt;li&gt;Advanced Probes&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
Re-Render Analysis

&lt;ul&gt;
&lt;li&gt;Dereferencing Objects&lt;/li&gt;
&lt;li&gt;Svelte's Re-Render Optimization&lt;/li&gt;
&lt;li&gt;Svelte Compiler Output&lt;/li&gt;
&lt;li&gt;Svelte's Reflexivity is Very Efficient&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
App Reactivity Tweaks

&lt;ul&gt;
&lt;li&gt;Finer Grained Dependency Management&lt;/li&gt;
&lt;li&gt;Preresolve Variations&lt;/li&gt;
&lt;li&gt;Optimization Caveats&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Extra Credit Exercise&lt;/li&gt;
&lt;li&gt;Who is this guy?&lt;/li&gt;
&lt;li&gt;Summary&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;As a general rule, I would recommend reading the article in it's entirety.  With that said, if you wish to &lt;strong&gt;"cut to the chase"&lt;/strong&gt;, I have summarized my findings at the end ... feel free to jump ahead to the Summary!&lt;/p&gt;

&lt;h2&gt;
  
  
  Video Presentation
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;If you are visually inclined&lt;/em&gt;, &lt;strong&gt;I gave the following presentation&lt;/strong&gt; to &lt;a href="https://sveltesummit.com/"&gt;Svelte Summit&lt;/a&gt; in the fall of 2021:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fvY1TAKNPgY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bit.ly/r-svelte"&gt;Full Syllabus &amp;amp; Resource Links&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Svelte Reactivity
&lt;/h2&gt;

&lt;p&gt;Being new to Svelte, I am absolutely fascinated with the fact that &lt;strong&gt;"reactivity is simply baked right into my app"&lt;/strong&gt;!  &lt;em&gt;This is sooooo kooool&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;In frameworks like React, your app must trigger reactivity &lt;em&gt;(with things like &lt;code&gt;setState()&lt;/code&gt;)&lt;/em&gt;, and the big focal point is: &lt;strong&gt;"When does my component re-render"&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;With Svelte, reactivity happens automatically, and it is much finer grained than the component level.  In Svelte, &lt;strong&gt;individual snippets of any component may dynamically re-generate at any time&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Svelte meticulously manages each snippet, monitoring and re-executing them as needed, based on changes in their dependent state.  Herein lies the beauty of Svelte: it accomplishes all of this automatically through it's compiler philosophy ... converting our declarative component-based code into JavaScript that incrementally manipulates the DOM directly!  Svelte both eliminates boilerplate code, and is truly reactive out-of-the-box, without employing a bloated in-memory run-time framework.  &lt;strong&gt;How kool is that?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So &lt;strong&gt;what&lt;/strong&gt; &lt;em&gt;(you may be asking)&lt;/em&gt; &lt;strong&gt;is a snippet&lt;/strong&gt;?  &lt;em&gt;This is actually &lt;strong&gt;my term&lt;/strong&gt;&lt;/em&gt;. For the purposes of this article, the term &lt;strong&gt;"snippet"&lt;/strong&gt; refers to any JavaScript expression that Svelte reactively manages and re-executes at the appropriate time &lt;em&gt;(i.e. whenever dependent state changes)&lt;/em&gt;.  Ultimately, snippets are used in providing the dynamics of our html markup &lt;em&gt;(i.e. it's reactivity)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Snippets may be found in two places&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;code-snippets&lt;/strong&gt;:&lt;br&gt;
&lt;strong&gt;code-snippets&lt;/strong&gt; are found in the component's JavaScript code &lt;em&gt;(within the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag)&lt;/em&gt;, and demarked with Svelte's &lt;code&gt;$:&lt;/code&gt; label.  This is referred to as &lt;strong&gt;Reactive Declarations&lt;/strong&gt; and &lt;strong&gt;Reactive Statements&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&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="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Generally speaking, &lt;strong&gt;code-snippets&lt;/strong&gt; are typically lightweight, in that they result in changes to JavaScript state variables.  With that said, however, the sole reason for these state changes is to be referenced in our html markup &lt;em&gt;(either directly or indirectly)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;In the sample above, the snippet will re-execute whenever the &lt;code&gt;user&lt;/code&gt; object changes &lt;em&gt;(the snippet's dependency)&lt;/em&gt;, re-assigning the &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;phone&lt;/code&gt; variables.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;html-snippets&lt;/strong&gt;:&lt;br&gt;
&lt;strong&gt;html-snippets&lt;/strong&gt; are found in the component's html markup, delineated through curly braces: &lt;code&gt;{...}&lt;/code&gt;.  This is commonly referred to as &lt;em&gt;&lt;strong&gt;interpolation&lt;/strong&gt;&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Hello {name}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;May we call you at {phone}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;html-snippets&lt;/strong&gt; are typically more heavyweight, in that &lt;strong&gt;they result in changes to the html DOM&lt;/strong&gt;!  &lt;em&gt;But hey ... that is the whole reason we are here&lt;/em&gt; ... i.e. &lt;strong&gt;the crux of our reactivity&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;In the sample above, the first snippet will re-generate it's html when &lt;code&gt;name&lt;/code&gt; changes, and the second when &lt;code&gt;phone&lt;/code&gt; changes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Terminology: snippet, code-snippet, and html-snippet
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Within this article, the term &lt;strong&gt;snippet&lt;/strong&gt; refers to any JavaScript expression that Svelte reactively manages and invokes when it's dependent state changes.&lt;/p&gt;

&lt;p&gt;Snippets may either be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;code-snippets&lt;/strong&gt; &lt;em&gt;(referred to as &lt;strong&gt;Reactive Declarations&lt;/strong&gt; and &lt;strong&gt;Reactive Statements&lt;/strong&gt;)&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;or &lt;strong&gt;html-snippets&lt;/strong&gt; &lt;em&gt;(commonly referred to as &lt;strong&gt;interpolation&lt;/strong&gt;)&lt;/em&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ultimately, snippets provide the dynamics within our html markup &lt;em&gt;(i.e. it's reactivity)&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Reactive Triggers
&lt;/h2&gt;

&lt;p&gt;So drilling into this topic just a bit more, you may be asking: &lt;strong&gt;How does Svelte determine when to trigger the re-execution our snippets?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The short answer is that Svelte monitors the dependent state referenced in each snippet, and triggers a re-execution whenever that state changes.&lt;/p&gt;

&lt;p&gt;The followup question is: &lt;strong&gt;How does Svelte determine that state references have changed?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The Svelte docs talk about &lt;strong&gt;"Assignments are 'reactive'"&lt;/strong&gt; and &lt;strong&gt;"Svelte's reactivity is triggered by assignment"&lt;/strong&gt;.  What they are saying is that Svelte triggers reactivity through assignment semantics &lt;em&gt;(recognizing assignment in it's various forms)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is true for the local state of a component.  The Svelte compiler will recognize assignment &lt;em&gt;(in it's various forms)&lt;/em&gt;, and mark the assigned variable as changed &lt;em&gt;(i.e. "stale")&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;However, I have discovered that there is a &lt;strong&gt;big distinction in whether the assignment target is a primitive or an object&lt;/strong&gt; &lt;em&gt;(including arrays)&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Primitive Types
&lt;/h3&gt;

&lt;p&gt;For primitive types &lt;em&gt;(strings, numbers, booleans, etc.)&lt;/em&gt;, reactivity only occurs when the value has changed.  In other words, it also incorporates JavaScript identity semantics (i.e. &lt;code&gt;priorState === nextState&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;myNum = (x + y) / 2&lt;/code&gt; will only be marked as "stale" when it's value actually changes.  If the prior value was 10 and the calculation resulted in 10, then no reactivity will occur.&lt;/p&gt;

&lt;p&gt;This is most certainly what one would expect, and I suppose it is rather obvious.  However the Svelte docs do not mention this &lt;em&gt;(as far as I can tell)&lt;/em&gt;.  The only reason I dwell on this point is that it is in stark contrast to object-based reactivity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Object Types
&lt;/h3&gt;

&lt;p&gt;Most applications require more complex state, typically modeled in objects &lt;em&gt;(or arrays)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;As it turns out, in Svelte, any technique by which you change an object, will mark the entire object as "stale".  This includes local component objects, Svelte object stores, component object properties, etc.  This is also true when you mutate an object, and inform Svelte that the object has changed &lt;em&gt;(by assigning it to itself)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This means that the granularity of change that is being tracked is much broader in scope.  In other words, the entire object will be considered "stale" even though only one property may have changed.&lt;/p&gt;

&lt;h4&gt;
  
  
  Insight: Reactivity is based on change in dependent state
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Snippet execution is triggered when dependent state changes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;primitive types trigger reactivity only when the value changes &lt;em&gt;(based on identity semantics)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;objects trigger reactivity per the entire object, not individual content&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Staleness Summary
&lt;/h3&gt;

&lt;p&gt;The following table highlights what Svelte will consider "stale":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Given:
   let prim  = 1945; // a primitive
   let myObj = {     // an object
     foo: 1945,
     bar: 1945,
   };

Operation                      Marks this as "stale"
=============================  ======================================
prim++                         prim
prim = 1945                    prim (ONLY if prior value is NOT 1945)

myObj.foo++                    myObj (all content of myObj)
myObj = {...myObj, foo:1945}   myObj (all content of myObj)
myObj.foo = 1945               myObj (all content of myObj)
myObj = myObj                  myObj (all content of myObj)
incrementFooIndirectly(myObj)  NOTHING
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see a demo of this in my &lt;a href="https://svelte.dev/repl/801a0a6bdc1f4ea08134425c18bb3e80?version=3.24.0"&gt;Reactive Triggers REPL&lt;/a&gt;.  This visualizes reflexive counts &lt;em&gt;(highlighted in yellow)&lt;/em&gt;, from the various operations &lt;em&gt;(listed above)&lt;/em&gt;.  In order to fully understand how this REPL works, you need to know what a &lt;code&gt;ReflectiveCounter&lt;/code&gt; is &lt;em&gt;(a new tool for your tool belt)&lt;/em&gt;.  This is discussed in the Advanced Diagnostics section.  You may want to come back to this REPL after reading the next section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exploring App Reactivity
&lt;/h2&gt;

&lt;p&gt;Being the curious fellow that I am, I want to see my app's reactivity.  After all, I am originally from Missouri - &lt;em&gt;&lt;strong&gt;the "Show-Me" State&lt;/strong&gt;&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;You might be saying: &lt;em&gt;"of course you can see the reactive results of your production app, through the state it is visualizing"&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BUT NO&lt;/strong&gt; ... that is NOT what I am talking about.  I want to definitively determine when Svelte triggers the execution of my snippets!  In other words, &lt;strong&gt;I want to see Svelte's reactivity in action&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;In so doing, this will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;help ground me in the Svelte philosophy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;give me insight on various Svelte heuristics &lt;em&gt;(dependency monitoring, reactive triggers, DOM updates, etc.)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;give me a better appreciation for &lt;strong&gt;"all this reactivity that is occurring (automatically) all around me"&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;and &lt;em&gt;we may just discover some detail that we hadn't considered&lt;/em&gt;!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, this is something that would be confined to a category of "diagnostic probes", and not part of our production app.&lt;/p&gt;

&lt;p&gt;At first glance, this seems like a "difficult task", because Svelte is in control of this &lt;em&gt;(not us)&lt;/em&gt;.  And &lt;strong&gt;Svelte Devtools&lt;/strong&gt; doesn't provide any insight on this either &lt;em&gt;(it's focus is on reviewing state at a given point-in-time)&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Diagnostic Logging Probes
&lt;/h2&gt;

&lt;p&gt;As it turn out, we can use a common "developer trick" to &lt;strong&gt;logically-OR a console.log() prefix&lt;/strong&gt; to each of our snippets.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Original:&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;p&amp;gt;&lt;/span&gt;Hello {name}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;May we call you at {phone}&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;&lt;strong&gt;With Logging Probes:&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;p&amp;gt;&lt;/span&gt;Hello {console.log('Name section fired) || name}&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;May we call you at {console.log('Phone section fired) || phone}&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;We have now prefixed each production expression with a &lt;code&gt;console.log()&lt;/code&gt; that is logically-ORed.  Because &lt;code&gt;console.log()&lt;/code&gt; returns nothing &lt;em&gt;(i.e. &lt;code&gt;undefined&lt;/code&gt; which is falsy)&lt;/em&gt;, the subsequent expression will unconditionally execute (resulting in the original html output).&lt;/p&gt;

&lt;p&gt;In other words, this will generate the same html &lt;em&gt;(as our original production code)&lt;/em&gt;, but with the &lt;strong&gt;addition of diagnostic logs that are &lt;em&gt;emitted only when the snippet is executed&lt;/em&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As an example, say our &lt;code&gt;phone&lt;/code&gt; state changes ... we will see the following emitted in our logs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;logs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Phone section fired
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see a &lt;strong&gt;live demo&lt;/strong&gt; of this in the Logging Probes discussion.&lt;/p&gt;

&lt;p&gt;It is &lt;strong&gt;important to use unique texts in each probe&lt;/strong&gt;, so as to be able to correlate each log entry to it's corresponding snippet.&lt;/p&gt;

&lt;p&gt;With the addition of these diagnostic probes, &lt;strong&gt;our logs will definitively reveal when Svelte re-executes each snippet ... very kool indeed!&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Takeaway: Monitor Svelte snippet invocations through logically-ORed prefixed expressions
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;You can detect when Svelte executes a snippet by prefixing it with a &lt;strong&gt;logically-ORed&lt;/strong&gt; monitor.&lt;/p&gt;

&lt;p&gt;This can be a simple logging probe or a more advanced ReflectiveCounter&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Advanced Diagnostics
&lt;/h2&gt;

&lt;p&gt;For most applications, these simple diagnostic logging probes will provide adequate insight into your app's reflexiveness.&lt;/p&gt;

&lt;p&gt;However, depending on how many probes you need, it may become tedious to correlate these logs to the various sections.&lt;/p&gt;

&lt;p&gt;In these cases we can replace the logs with a simple monitor, that &lt;strong&gt;exposes a reflective-count for each section, &lt;em&gt;displayed directly on our page&lt;/em&gt;&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Here is the utility:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;createReflectiveCounters.js&lt;/strong&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;logMsg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// our base writable store&lt;/span&gt;
  &lt;span class="c1"&gt;// ... -1 accounts for our initial monitor reflection (bumping it to 0)&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;subscribe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;set&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;update&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;(&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="c1"&gt;// expose our newly created custom store&lt;/span&gt;
  &lt;span class="k"&gt;return&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;monitor&lt;/span&gt;&lt;span class="p"&gt;(...&lt;/span&gt;&lt;span class="nx"&gt;monitorDependents&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;update&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="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="c1"&gt;// increment our count&lt;/span&gt;
      &lt;span class="nx"&gt;logMsg&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;logMsg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// optionally log (when msg supplied)&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// prevent rendering `undefined` on page (when used in isolation)&lt;/span&gt;
                 &lt;span class="c1"&gt;// ... still `falsy` when logically-ORed&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;reset&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="kd"&gt;set&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="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 creates a &lt;code&gt;ReflectiveCounter&lt;/code&gt; (a custom store), suitable to be used in monitoring Svelte reflective counts.&lt;/p&gt;

&lt;p&gt;In it's rudimentary form, a &lt;code&gt;ReflectiveCounter&lt;/code&gt; is just a simple counter, however it's API is tailored to be used as a reflective monitor.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;monitor()&lt;/code&gt; method should be prefixed in a "Svelte invoked" snippet (either through a &lt;strong&gt;logically-ORed&lt;/strong&gt; expression, or a &lt;strong&gt;JS comma operator&lt;/strong&gt;).  It maintains a count of how often Svelte executes this snippet.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: &lt;code&gt;&amp;lt;i&amp;gt;{fooSectionReflexiveCount.monitor() || $foo}&amp;lt;/i&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In turn these counts can be summarized directly on your page!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: &lt;code&gt;&amp;lt;mark&amp;gt;{$fooSectionReflexiveCount}:&amp;lt;/mark&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;code&gt;monitor()&lt;/code&gt; method may also be optionally supplied a set of &lt;code&gt;monitorDependent&lt;/code&gt; parameters.  This is used when the dependents you wish to monitor are NOT already part of the production snippet.  Technically the utility does &lt;strong&gt;not&lt;/strong&gt; use these parameters, rather it merely informs Svelte to monitor these dependents as criteria for re-invoking the snippet.  The following example monitors how many times a Svelte store has changed:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: &lt;code&gt;$: fooStateChangeCount.monitor($foo);&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You may also optionally console log a message, &lt;em&gt;whenever the monitor() is executed&lt;/em&gt;, by supplying a &lt;code&gt;logMsg&lt;/code&gt; to the creator:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;: &lt;code&gt;const fooSectionReflexiveCount = createReflectiveCounter('Foo section fired');&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;code&gt;reset()&lt;/code&gt; method can be used to reset the given count.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;USAGE:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two distinct ways that &lt;code&gt;ReflectiveCounter&lt;/code&gt; can be used:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Monitor html reflexive counts (in html-snippets):&lt;br&gt;
&lt;/p&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;fooReflexiveCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&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 section fired&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="c"&gt;&amp;lt;!-- diagnostic reporter --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$fooReflexiveCount}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- monitor this section --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;{fooReflexiveCount.monitor() || $foo}&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- reset counts --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{fooReflexiveCount.reset}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Reset&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Monitor state change counts (in code-snippets):&lt;br&gt;
&lt;/p&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;fooChangeCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&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;fooChangeCount&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;monitor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$foo&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="c"&gt;&amp;lt;!-- reporter/resetter --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;$foo state change counts: {$fooChangeCount}&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;on:click=&lt;/span&gt;&lt;span class="s"&gt;{fooChangeCount.reset}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Reset&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can see a &lt;strong&gt;live demo&lt;/strong&gt; of &lt;code&gt;ReflectiveCounters&lt;/code&gt; in the Advanced Probes discussion.&lt;/p&gt;

&lt;h4&gt;
  
  
  Insight: Diagnostic probes are temporary
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Diagnostic probes should be considered temporary, and removed &lt;em&gt;(or commented out)&lt;/em&gt; when your analysis is complete.&lt;/p&gt;

&lt;p&gt;There are techniques where they can be disabled at run-time &lt;em&gt;(with minimal overhead)&lt;/em&gt;, but this exercise is left up to the reader.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Demo App
&lt;/h2&gt;

&lt;p&gt;Before we can begin any analysis, we will need some code to play with.  It should be simple and focused, so we can concentrate on it's reactivity.&lt;/p&gt;

&lt;p&gt;I have created an interactive demo (a Svelte REPL) that we can use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jQKgoaI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rih5xpcbip28xdleteeq.png" class="article-body-image-wrapper"&gt;&lt;img alt="Greet User Operation" src="https://res.cloudinary.com/practicaldev/image/fetch/s--jQKgoaI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rih5xpcbip28xdleteeq.png" width="526" height="698"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The basic idea behind the demo is you can &lt;strong&gt;maintain the characteristics of a logged-in user&lt;/strong&gt; &lt;em&gt;(the top-half: &lt;code&gt;EditUser.svelte&lt;/code&gt;)&lt;/em&gt;, and &lt;strong&gt;display them&lt;/strong&gt; &lt;em&gt;(the bottom half: &lt;code&gt;GreetUser.svelte&lt;/code&gt;)&lt;/em&gt; ... pretty simple :-) You can update one or more properties of the user by simply changing the text, and clicking the &lt;code&gt;Apply Change&lt;/code&gt; button.  &lt;em&gt;&lt;strong&gt;Go ahead and play with the interactive demo now&lt;/strong&gt;&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;The demo is broken up into a number of modules. I won't detail them here ... they are summarized in &lt;code&gt;App.svelte&lt;/code&gt; (of the &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SideBar&lt;/strong&gt;: Normally the &lt;code&gt;EditUser&lt;/code&gt;/&lt;code&gt;GreetUser&lt;/code&gt; components would be mutually exclusive &lt;em&gt;(i.e. displayed at different times)&lt;/em&gt; ... I merely &lt;strong&gt;combined them&lt;/strong&gt; so we can &lt;strong&gt;better see the "reflexive correlation" between the two&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For our discussions, we will be focusing on a single module: the &lt;code&gt;GreetUser&lt;/code&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GreetUser.svelte&lt;/strong&gt; &lt;em&gt;(see &lt;code&gt;GU1_original.svelte&lt;/code&gt; in &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;)&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;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
 &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;user&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;./user.js&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;hr/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;Greet User &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;(original)&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Hello {$user.name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  May we call you at:
  &lt;span class="nt"&gt;&amp;lt;i&lt;/span&gt; &lt;span class="na"&gt;class:long-distance=&lt;/span&gt;&lt;span class="s"&gt;{$user.phone.startsWith('1-')}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {$user.phone}
  &lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;?
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
 &lt;span class="nc"&gt;.long-distance&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;pink&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This component merely greets the logged-in user &lt;em&gt;(an object-based Svelte store)&lt;/em&gt;, visualizing individual properties of the user.  Long distance phone numbers will be highlighted &lt;em&gt;(when they begin with "1-")&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What could be simpler than this?&lt;/strong&gt; This should provide a good basis for our discussions :-)&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspecting App Reactivity
&lt;/h2&gt;

&lt;p&gt;Let's enhance the &lt;code&gt;GreetUser&lt;/code&gt; component with our &lt;strong&gt;Diagnostic Probes&lt;/strong&gt; &lt;em&gt;(discussed in Exploring App Reactivity)&lt;/em&gt; to see how well it behaves.&lt;/p&gt;

&lt;h3&gt;
  
  
  Logging Probes
&lt;/h3&gt;

&lt;p&gt;Here is our &lt;code&gt;GreetUser&lt;/code&gt; component with the Diagnostic Logging Probes applied:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GreetUser.svelte&lt;/strong&gt; &lt;em&gt;(see &lt;code&gt;GU2_logDiag.svelte&lt;/code&gt; in &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;)&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;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
 &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;user&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;./user.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;// diagnostic probes monitoring reflection&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;probe1&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;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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Name  section fired&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;probe2&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;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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone class   fired&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;probe3&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;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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone section fired&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;hr/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;Greet User &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;(with reflexive diagnostic logs)&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Hello {probe1() || $user.name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  May we call you at:
  &lt;span class="nt"&gt;&amp;lt;i&lt;/span&gt; &lt;span class="na"&gt;class:long-distance=&lt;/span&gt;&lt;span class="s"&gt;{probe2()&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="na"&gt;user.phone.startsWith&lt;/span&gt;&lt;span class="err"&gt;('1&lt;/span&gt;&lt;span class="na"&gt;-&lt;/span&gt;&lt;span class="err"&gt;')}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {probe3() || $user.phone}
  &lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;?
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
 &lt;span class="nc"&gt;.long-distance&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;pink&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run this version of the &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt; by selecting: with reflexive diagnostic logs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qwiotBOX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vur99iu5vmokq5vaiknl.png" class="article-body-image-wrapper"&gt;&lt;img alt="Logs show snippet execution!" src="https://res.cloudinary.com/practicaldev/image/fetch/s--qwiotBOX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vur99iu5vmokq5vaiknl.png" width="527" height="699"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Very nice&lt;/strong&gt; ... by analyzing the logs, we can determine exactly when individual html-snippets are re-executed!&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Probes
&lt;/h3&gt;

&lt;p&gt;Let's also apply the Advanced Diagnostics &lt;em&gt;(just for fun)&lt;/em&gt;, to see what they look like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GreetUser.svelte&lt;/strong&gt; &lt;em&gt;(see &lt;code&gt;GU3_advancedDiag.svelte&lt;/code&gt; in &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;)&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;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
 &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;user&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;./user.js&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;createReflectiveCounter&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;./createReflectiveCounter.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;// diagnostic probes monitoring reflection&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;probe1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&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  section fired&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;probe2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone class   fired&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;probe3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone section fired&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;hr/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;Greet User &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;(with advanced on-screen diagnostics)&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$probe1}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;
  Hello {probe1.monitor() || $user.name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$probe2}/{$probe3}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;
  May we call you at:
  &lt;span class="nt"&gt;&amp;lt;i&lt;/span&gt; &lt;span class="na"&gt;class:long-distance=&lt;/span&gt;&lt;span class="s"&gt;{probe2.monitor()&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="na"&gt;user.phone.startsWith&lt;/span&gt;&lt;span class="err"&gt;('1&lt;/span&gt;&lt;span class="na"&gt;-&lt;/span&gt;&lt;span class="err"&gt;')}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {probe3.monitor() || $user.phone}
  &lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;?
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
 &lt;span class="nc"&gt;.long-distance&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;pink&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run this version of the &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt; by selecting: with advanced on-screen diagnostics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ep-rzd5r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9usvx4xj0nm4ssstjgvs.png" class="article-body-image-wrapper"&gt;&lt;img alt="On Screen Probes" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ep-rzd5r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9usvx4xj0nm4ssstjgvs.png" width="527" height="699"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Great&lt;/strong&gt; ... our component's reactivity is now visible, directly on our page!&lt;/p&gt;

&lt;h2&gt;
  
  
  Re-Render Analysis
&lt;/h2&gt;

&lt;p&gt;So there seems to be some &lt;strong&gt;unexpected results&lt;/strong&gt;, revealed through the introduction of our diagnostic probes.  &lt;em&gt;We are seeing html-snippets re-execute when their state did NOT change &lt;strong&gt;(ouch)&lt;/strong&gt;!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s3GOt74q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ja62w2kxt6lbfbm13dd0.png" class="article-body-image-wrapper"&gt;&lt;img alt="NO Changes, but still re-fired" src="https://res.cloudinary.com/practicaldev/image/fetch/s--s3GOt74q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ja62w2kxt6lbfbm13dd0.png" width="528" height="698"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see this by changing a single property &lt;em&gt;(say name)&lt;/em&gt;, and notice that all three of our html-snippets re-execute!  You can even click &lt;code&gt;Apply Change&lt;/code&gt; button with no property changes, and still ... all three of our html-snippets re-execute!  &lt;em&gt;&lt;strong&gt;SideBar&lt;/strong&gt;: I realize I can optimize the &lt;code&gt;user&lt;/code&gt; store to prevent this last scenario, but for the purposes of this discussion, it better highlights the point we are driving at.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;So what is going on?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Dereferencing Objects
&lt;/h3&gt;

&lt;p&gt;If you remember our discussion of Reactive Triggers, this is actually an example of an object reference being overly broad in it's dependency granularity.&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;p&amp;gt;&lt;/span&gt;Hello {$user.name}!&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;Because Svelte has marked the &lt;code&gt;$user&lt;/code&gt; object as being stale, any html-snippet that references that object will re-execute, regardless of whether the dereferenced &lt;code&gt;.name&lt;/code&gt; has changed or not!&lt;/p&gt;

&lt;p&gt;At first glance, this &lt;strong&gt;seems counter intuitive&lt;/strong&gt;.  &lt;em&gt;Why would Svelte do this?&lt;/em&gt; &lt;strong&gt;Is this in fact causing redundant and unnecessary re-renders in our DOM&lt;/strong&gt;? ... &lt;em&gt;&lt;strong&gt;Spoiler Alert&lt;/strong&gt;: No redundant re-renders are occurring, but we will discuss this in the next section!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Well if you stop and think about this, in order for Svelte to monitor an object's dereferenced content, it would have to pre-execute sub-expressions found within the snippet, and monitor the resulting value.&lt;/p&gt;

&lt;p&gt;In our simple example, that may technically be possible, but as a general rule this is a bad idea, for a variety of reasons.&lt;/p&gt;

&lt;p&gt;The primary reason being that in order to accomplish this, these sub-expressions &lt;strong&gt;would always need to be executed&lt;/strong&gt;, and that goes against the basic tenet of what Svelte is trying to do (i.e. it's reactive triggering mechanism) ... that is: &lt;em&gt;Should this snippet be re-executed or not?&lt;/em&gt; If Svelte had to pre-execute parts of the snippet to make this determination, there could be negative side-effects!  For example, the sub-expression could be invoking a method that applies unwanted mutations, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SideBar&lt;/strong&gt;: My explanation here is my "best guess", based on intuition.  If I receive comments from "in the know" Svelte maintainers, I will make any needed corrections (to the explanation) and remove this SideBar :-) Regardless of the the explanation, this is in fact how Svelte works!&lt;/p&gt;

&lt;h3&gt;
  
  
  Svelte's Re-Render Optimization
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;So what does this mean?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The "elephant in the room" is: &lt;strong&gt;Is this actually producing redundant and unnecessary re-renders in our DOM?&lt;/strong&gt; Remember: &lt;strong&gt;DOM updates are expensive&lt;/strong&gt;!  Is this really true, &lt;em&gt;or is there more going on "under the covers"&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;It occurred to me that just because Svelte decided to re-execute my html-snippet, doesn't necessarily mean that it resulted in a DOM update.&lt;/p&gt;

&lt;p&gt;Could it be that Svelte further optimizes this process by insuring the result of an html-snippet actually changed?  If you think about it, this makes a lot of sense for Svelte to do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In this particular case, an unnecessary html-snippet re-executed because of an overly broad dependency granularity ... i.e. an object verses it's individual content &lt;em&gt;(we discussed this in the Reactive Triggers section)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are other cases, however, where our html-snippet could return the same result, even when it's dependencies legitimately change.  Think about it: this is application code &lt;em&gt;(outside the control of Svelte)&lt;/em&gt;.  Consider a case where our app requirements will group a set of enumerated values in to one classification, generating the same result from multiple values.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As it turns out, &lt;strong&gt;Svelte does in fact optimize it's DOM updates by insuring the content has actually changed&lt;/strong&gt; ... &lt;em&gt;so there are no redundant re-renders&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Svelte comes to our rescue once again&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;I initially determined this by &lt;strong&gt;going into a debugging session of one of my diagnostic probes&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;By stepping out one level &lt;em&gt;(into the Svelte world)&lt;/em&gt;, I found myself in some rather cryptic code, where a rather complex conditional was executing a helper function that actually performed the low-level DOM update.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Being a little uncertain about this complex conditional, I decided to merely set a break-point on that helper function.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This allowed me to interact with my app, and determine that: &lt;strong&gt;sure enough&lt;/strong&gt; ... &lt;em&gt;the &lt;strong&gt;DOM fragments only update (i.e. re-render) when the the result of the html-snippet actually changed&lt;/strong&gt;&lt;/em&gt;!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;THIS IS SOOO KOOOL&lt;/strong&gt;!&lt;/p&gt;

&lt;h3&gt;
  
  
  Svelte Compiler Output
&lt;/h3&gt;

&lt;p&gt;OK, &lt;strong&gt;now I was starting to get cocky&lt;/strong&gt;.  I started wondering: &lt;em&gt;how efficient is Svelte in making this "content change" determination&lt;/em&gt;?  I kept thinking more about this cryptic code where I found myself &lt;em&gt;(in the debugging session)&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Could it be that this code was the output of the Svelte compiler?  ... You know, that &lt;strong&gt;"JS output"&lt;/strong&gt; REPL tab, that you were &lt;strong&gt;always afraid to click on&lt;/strong&gt;?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Sure enough my hunch was right&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;With this newfound confidence, &lt;strong&gt;dare I attempt to make sense of this cryptic code&lt;/strong&gt;? ... &lt;em&gt;well it's worth a try&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caveat&lt;/strong&gt;: This section is &lt;strong&gt;completely optional&lt;/strong&gt;.  We have already discussed the key takeaway that you need to know on this topic.  Therefore, &lt;strong&gt;this section is strictly for extra credit only&lt;/strong&gt; &lt;em&gt;(albeit very interesting to real geeks)&lt;/em&gt;!  Feel free to skip ahead to the next section.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FYI&lt;/strong&gt;: I won't clutter up the article with a lot of this cryptic code ... you can follow along by viewing the &lt;strong&gt;"JS output"&lt;/strong&gt; tab from the &lt;a href="//use%20the%20%20raw%20%60GU1_original.svelte%60%20endraw%20%20module"&gt;Demo REPL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;So here goes ...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cryptic Names:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first thing you will notice is that the variable names in this code aren't incredibility intuitive ... mostly numbered variables with single letter prefixes.  But hey: this is machine-generated code! We wouldn't want lengthy, intuitive names bloating the size of our bundle!  Actually, once you get the hang of it, there are some useful patterns in the names ... &lt;em&gt;keep reading&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DOM Fragments:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The most important takeaway of this code is that Svelte has managed to break down our html into fragments that can be re-built at the lowest level of our DOM tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is a crucial point&lt;/strong&gt;!  Once this has been accomplished, it becomes rather trivial to incrementally process change!&lt;/p&gt;

&lt;p&gt;My intuition tells me that this is probably the most complex aspect of the compiler.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;For static html &lt;em&gt;(that does not vary)&lt;/em&gt;, it even uses a simple approach of &lt;code&gt;innerHTML&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, this:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;Greet User &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;(original)&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Generated this:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;p0&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;p&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;p0&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="s2"&gt;`&amp;lt;b&amp;gt;Greet User &amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;(original)&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;em&gt;&lt;strong&gt;Now this, I can handle&lt;/strong&gt;&lt;/em&gt; :-)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;For dynamic html content &lt;em&gt;(driven by an html-snippet/interpolation)&lt;/em&gt;, it further breaks down the html into the needed individual DOM elements &lt;em&gt;(which can be incrementally updated)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For example, this:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Hello {$user.name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Generated this:&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// from the c() method ...&lt;/span&gt;
&lt;span class="nx"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;p&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;t4&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;t5&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t5_value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;t6&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// from the m() method ...&lt;/span&gt;
&lt;span class="nx"&gt;insert&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;p1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;anchor&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;t4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;t5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;t6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;Notice that for dynamic content, Svelte is keeping track of two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the &lt;code&gt;t5&lt;/code&gt; text dom element&lt;/li&gt;
&lt;li&gt;and the &lt;code&gt;t5_value&lt;/code&gt; text content ... &lt;em&gt;&lt;strong&gt;this must be the output of our html-snippet&lt;/strong&gt;&lt;/em&gt;!&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;&lt;strong&gt;Naming Conventions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Are you starting to get a feel for some of the naming conventions?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;p&lt;/code&gt; is for paragraph&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;t&lt;/code&gt; is for text nodes&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Component Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The component contains several methods.  In reviewing their implementation, I think I can infer the following characteristics:&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;// appears to be initializing our internal state&lt;/span&gt;
&lt;span class="nx"&gt;c&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;snip&lt;/span&gt; &lt;span class="nx"&gt;snip&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// appears to be the initial build-up of our DOM&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;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;anchor&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;snip&lt;/span&gt; &lt;span class="nx"&gt;snip&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// appears to be the incremental update of our DOM fragments&lt;/span&gt;
&lt;span class="c1"&gt;// ... THIS IS THE KEY FOCUS OF OUR REACTIVITY (analyzed below)&lt;/span&gt;
&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;dirty&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;snip&lt;/span&gt; &lt;span class="nx"&gt;snip&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// appears to be removing our DOM&lt;/span&gt;
&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;detaching&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;snip&lt;/span&gt; &lt;span class="nx"&gt;snip&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;More on Naming Conventions:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hey ... these names are starting to make sense, once you realize we are playing the &lt;a href="https://muppet.fandom.com/wiki/The_Alphabet_Game"&gt;Sesame Street Alphabet Game&lt;/a&gt;!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;c()&lt;/code&gt; is for &lt;code&gt;constructor()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;m()&lt;/code&gt; is for &lt;code&gt;mount()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;p()&lt;/code&gt; is for &lt;code&gt;partiallyPutinProgressivePermutations()&lt;/code&gt; ... &lt;em&gt;I obviously have &lt;strong&gt;NO IDEA&lt;/strong&gt; on this one&lt;/em&gt; :-( &lt;a href="https://twitter.com/mark_volkmann"&gt;Mark&lt;/a&gt; later informed me it stands for &lt;code&gt;update()&lt;/code&gt; &lt;em&gt;(using the second letter)&lt;/em&gt;, and provided a reference to a &lt;a href="https://lihautan.com/compile-svelte-in-your-head-part-1/"&gt;Tan Li Hau resource&lt;/a&gt; ... &lt;em&gt;where was this when I needed it&lt;/em&gt;? :-)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;d()&lt;/code&gt; is for &lt;code&gt;destroy()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;There are a number of methods that are not operational (e.g. &lt;code&gt;i: noop&lt;/code&gt;, etc.), so we obviously have NOT hit the more advanced cases with our very simple component :-)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Incremental Updates:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The primary method we are interested in is the &lt;code&gt;p()&lt;/code&gt; method.  This is where the incremental DOM updates occur.  It is where I found myself in the debugging session, when I determined that the DOM updates were optimized.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Notice it has 3 sections of code &lt;em&gt;(each prefixed with a conditional - &lt;code&gt;if&lt;/code&gt;)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WowZee ... our component definition also has 3 html-snippets &lt;em&gt;(what a coincidence)&lt;/em&gt;!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Let's look at one of them &lt;em&gt;(I have reformatted the JS just a bit, and added the &lt;code&gt;//&lt;/code&gt; comments)&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;html code fragment&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Hello {$user.name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;strong&gt;compiled output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;dirty&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// one of 3 sections ...&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;dirty&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="cm"&gt;/*$user*/&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;                                  &lt;span class="c1"&gt;// conditional Part I&lt;/span&gt;
      &lt;span class="nx"&gt;t5_value&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t5_value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="cm"&gt;/*$user*/&lt;/span&gt; &lt;span class="nx"&gt;ctx&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="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="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="c1"&gt;// conditional Part II&lt;/span&gt;
    &lt;span class="nx"&gt;set_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;t5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;t5_value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;                                   &lt;span class="c1"&gt;// the payload - update the DOM!&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt; &lt;span class="nx"&gt;snip&lt;/span&gt; &lt;span class="nx"&gt;snip&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

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

&lt;p&gt;Here is my analysis:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;ctx[]&lt;/code&gt; array contains all our dependencies.  &lt;code&gt;ctx[0]&lt;/code&gt; happens to be our &lt;code&gt;$user&lt;/code&gt; object &lt;em&gt;(thanks to the compiler retained comment hints)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;dirty&lt;/code&gt; contains a bitwise accumulation of the "staleness" of ALL our dependent variables &lt;em&gt;(one bit for each dependent)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Part I of the conditional is pulling out the dirty flag of the &lt;code&gt;$user&lt;/code&gt; dependent variable &lt;em&gt;(using the bit-wise AND operator - &lt;code&gt;&amp;amp;&lt;/code&gt;)&lt;/em&gt;.  This determines if our &lt;code&gt;$user&lt;/code&gt; variable is stale.  If it is, we will continue on to Part II (via the &lt;code&gt;logical-AND&lt;/code&gt; operator - &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Part II of the conditional is actually doing two things: It is assigning the latest &lt;code&gt;t5_value&lt;/code&gt; from our html-snippet &lt;em&gt;(after converting it to a string: &lt;code&gt;+ ""&lt;/code&gt;)&lt;/em&gt;, &lt;strong&gt;AND&lt;/strong&gt; it is comparing the prior/next snippet output (using identity semantics: &lt;code&gt;!==&lt;/code&gt;).  Only when the prior/next has changed will it execute the conditional payload &lt;em&gt;(i.e. &lt;strong&gt;update the DOM&lt;/strong&gt;)&lt;/em&gt;.  Ultimately this conditional is a very simple primitive string comparison!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;set_data()&lt;/code&gt; function is a Svelte helper utility that actually updates the DOM!  You can find these utils &lt;a href="https://github.com/sveltejs/svelte/blob/master/src/runtime/internal/dom.ts"&gt;on GitHub here&lt;/a&gt;, or simply open them from your installed &lt;code&gt;node_modules/svelte/internal/index.js&lt;/code&gt;.  This particular utility merely sets the supplied data in a DOM text element:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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="nx"&gt;set_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;text&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="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="dl"&gt;''&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;data&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;text&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="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nx"&gt;text&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="nx"&gt;data&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;
  
  
  Svelte's Reflexivity is Very Efficient
&lt;/h3&gt;

&lt;p&gt;Well that was fun!  &lt;em&gt;A very interesting exercise&lt;/em&gt;! &lt;strong&gt;What have we learned&lt;/strong&gt;?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Don't be afraid to open the &lt;strong&gt;"JS output"&lt;/strong&gt; tab of your REPL!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Big Bird would do well in a Svelte code review!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Most importantly&lt;/strong&gt;, &lt;em&gt;the following insight&lt;/em&gt;:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Insight: Svelte's reflexivity is very efficient!
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;The component's DOM representation is highly optimized, broken down into fragments that can be re-built at the lowest level of our DOM tree.&lt;/p&gt;

&lt;p&gt;Dynamic content is gleaned from executing html-snippets.&lt;/p&gt;

&lt;p&gt;Reflection is triggered by dependent state changes.&lt;/p&gt;

&lt;p&gt;DOM updates occur only when the content has actually changed &lt;em&gt;(using a very light-weight string comparison)&lt;/em&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Who could ask for anything more&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kudos&lt;/strong&gt; go out to &lt;a href="https://twitter.com/Rich_Harris"&gt;Rich Harris&lt;/a&gt; and the &lt;a href="https://github.com/sveltejs/svelte/graphs/contributors"&gt;Core Contributors&lt;/a&gt; for being so smart and thorough!&lt;/p&gt;

&lt;h2&gt;
  
  
  App Reactivity Tweaks
&lt;/h2&gt;

&lt;p&gt;We have learned that there is a subtle distinction between &lt;strong&gt;reflection&lt;/strong&gt; &lt;em&gt;(Svelte's execution of html-snippets)&lt;/em&gt; and &lt;strong&gt;re-rendering&lt;/strong&gt; &lt;em&gt;(applying DOM updates)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Just because Svelte has decided to run an html-snippet &lt;em&gt;(through it's dependency monitoring)&lt;/em&gt;, doesn't mean that a DOM update is applied &lt;em&gt;(although it typically is)&lt;/em&gt; ... &lt;em&gt;because the snippet could return the same result&lt;/em&gt;.  Svelte optimizes this process to insure DOM updates only occur when they actually change.&lt;/p&gt;

&lt;p&gt;As a result, our reflection count can be slightly larger than the re-rendering count.  There are two reasons for this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;An overly broad dependency granularity &lt;em&gt;(e.g. the difference between objects and primitives)&lt;/em&gt;.  This one is on the shoulders of Svelte.  As an example, Svelte has invoked our snippet because of an object change, but the object's sub-content &lt;em&gt;(used by our snippet)&lt;/em&gt; hasn't really changed.  We will discuss this further in: Finer Grained Dependency Management&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The html-snippet could return the same result for multiple dependent values. This is on the shoulders of our App.  Consider the case where our app requirements will group a set of enumerated values in to one classification, generating the same result from multiple values.  We will discuss this further in: Preresolve Variations&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Regardless of who's shoulders these conditions emerge, &lt;strong&gt;there are app-specific techniques by which we can narrow this gap&lt;/strong&gt; &lt;em&gt;(even to zero)&lt;/em&gt;.  So how can we impact this?  After all, Svelte is the one who is in control of executing our html-snippets.  How can we alter this?&lt;/p&gt;

&lt;p&gt;The basic thrust of what we are about to do is to &lt;strong&gt;move a portion of our reflexivity FROM html-snippets TO code-snippets&lt;/strong&gt;.  Remember, we mentioned that code-snippets typically have less overhead &lt;em&gt;(because they merely result in changes to JavaScript state variables)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Why would you want to do this?  Does it really represent a significant optimization?  Well, consider this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What if this discrepancy count were large &lt;em&gt;(where we were needlessly re-executing an html-snippet many times with the same output)&lt;/em&gt;?&lt;/li&gt;
&lt;li&gt;And what if the overhead of executing this html-snippet were extremely high?&lt;/li&gt;
&lt;li&gt;What if the same html-snippet were needed in multiple places in our html?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Keep in mind, we do not have these conditions in our simple toy app ... but for sake of example, let's pretend that we do!&lt;/p&gt;

&lt;p&gt;Regarding the optimization question ... to be honest, most likely the techniques we are about to discuss will not significantly impact your app's performance.  In some cases, we will just be moving an optimization that Svelte was already doing, into the application realm.  With that said, the best opportunity for an optimization is bullet point 3 (above).&lt;/p&gt;

&lt;p&gt;So why go through this exercise?  Very simply: &lt;em&gt;&lt;strong&gt; to better understand the finer characteristics of Svelte's reactivity&lt;/strong&gt;&lt;/em&gt;!  This knowledge can give you the edge that separates the senior developers ... knowing the impact of finer-grained tweaks ... pulling in the big bucks ... &lt;em&gt;we can only hope&lt;/em&gt;!&lt;/p&gt;

&lt;h4&gt;
  
  
  Extreme Optimization: Prefer reactivity in code-snippets verses html-snippets
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;The overhead of &lt;strong&gt;code-snippets&lt;/strong&gt; are typically very light, because they merely change JavaScript state variables.&lt;/p&gt;

&lt;p&gt;While it is true that variable changes can result in html DOM changes &lt;em&gt;(by stimulating a dependent &lt;strong&gt;html-snippet&lt;/strong&gt;)&lt;/em&gt;, this will be canceled out, when the dependent variable is unchanged &lt;em&gt;(within the &lt;strong&gt;code-snippet&lt;/strong&gt;)&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Finer Grained Dependency Management
&lt;/h2&gt;

&lt;p&gt;This section addresses Svelte's overly broad dependency granularity, as it relates to Primitive Types verses Object Types.&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;GreetUser&lt;/code&gt; component is currently dereferencing the &lt;code&gt;$user&lt;/code&gt; object within it's html.  This is causing Svelte to execute our html-snippets in cases where the dereferenced property has not changed.&lt;/p&gt;

&lt;p&gt;We can change this by simply normalizing our referenced state into primitive types.&lt;/p&gt;

&lt;h4&gt;
  
  
  Takeaway: Fine Tune Svelte's Dependency Management by using primitive types
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;When an html-snippet dereferences an object that has the potential of changing (e.g. &lt;code&gt;user.name&lt;/code&gt;), this may result in a false-positive condition.&lt;/p&gt;

&lt;p&gt;Svelte will re-execute the snippet based on whether the top-level object has changed (e.g. &lt;code&gt;user&lt;/code&gt;), and not the dereferenced result!&lt;/p&gt;

&lt;p&gt;You can change this by depending on primitive types &lt;em&gt;normalized from the object (say through a code-snippet)&lt;/em&gt;, giving the html-snippet finer granularity in what triggers it's execution.&lt;/p&gt;

&lt;p&gt;html-snippets that depend on primitive types will only execute when their dependent values change &lt;em&gt;(based on identity semantics)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is really an application of the Extreme Optimization: Prefer reactivity in code-snippets verses html-snippets.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is our &lt;code&gt;GreetUser&lt;/code&gt; component with the applied change:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GreetUser.svelte&lt;/strong&gt; &lt;em&gt;(see &lt;code&gt;GU4_primNorm.svelte&lt;/code&gt; in &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;)&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;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
 &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;user&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;./user.js&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;createReflectiveCounter&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;./createReflectiveCounter.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;// FOCUS: with primitive normalization&lt;/span&gt;
 &lt;span class="c1"&gt;// normalize our referenced state with primitive types&lt;/span&gt;
 &lt;span class="c1"&gt;// ... html-snippets will only fire when values actually change&lt;/span&gt;
 &lt;span class="c1"&gt;// ... using JS identity semantics&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="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="c1"&gt;// diagnostic probes monitoring reflection&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;probe1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&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  section fired&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;probe2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone class   fired&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;probe3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone section fired&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;hr/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;Greet User &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;(with primitive normalization)&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$probe1}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;
  Hello {probe1.monitor() || name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$probe2}/{$probe3}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;
  May we call you at:
  &lt;span class="nt"&gt;&amp;lt;i&lt;/span&gt; &lt;span class="na"&gt;class:long-distance=&lt;/span&gt;&lt;span class="s"&gt;{probe2.monitor()&lt;/span&gt; &lt;span class="err"&gt;||&lt;/span&gt; &lt;span class="na"&gt;phone.startsWith&lt;/span&gt;&lt;span class="err"&gt;('1&lt;/span&gt;&lt;span class="na"&gt;-&lt;/span&gt;&lt;span class="err"&gt;')}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {probe3.monitor() || phone}
  &lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;?
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
 &lt;span class="nc"&gt;.long-distance&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;pink&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run this version of the &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt; by selecting: with primitive normalization.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I9X6-Bv9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xcy8ejg8rq18f7a0qx6p.png" class="article-body-image-wrapper"&gt;&lt;img alt="No Changes, NO re-fire ... FIXED" src="https://res.cloudinary.com/practicaldev/image/fetch/s--I9X6-Bv9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xcy8ejg8rq18f7a0qx6p.png" width="530" height="697"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Great&lt;/strong&gt;: Notice that the &lt;strong&gt;reflection counts&lt;/strong&gt; &lt;em&gt;(Svelte's execution of html-snippets)&lt;/em&gt; now correctly reflect actual changes to the corresponding state!&lt;/p&gt;

&lt;p&gt;In this example, the "primitive normalization" was accomplished in the component code-snippet:&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;$&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="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the &lt;code&gt;$user&lt;/code&gt; object changes, this normalization code will be re-executed.  However, because our html-snippets utilize the &lt;code&gt;name&lt;/code&gt;/&lt;code&gt;phone&lt;/code&gt; primitives, &lt;strong&gt;only the snippets that depend on the properties that truly changed will re-execute! ... &lt;em&gt;very kool!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This "primitive normalization" can be accomplished in a variety of ways.  In our example, it was carried out in the component code.  Another way you could accomplish this is to &lt;strong&gt;promote derived stores&lt;/strong&gt;, that pull a single value out.  For example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;user.js&lt;/strong&gt; &lt;em&gt;(modified)&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="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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;writable&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="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;phone&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="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;derived&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&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;u&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;phone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;derived&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&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;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Preresolve Variations
&lt;/h2&gt;

&lt;p&gt;This section addresses the case where an html-snippet generates the same result for multiple dependent values.  This typically occurs when the snippet contains conditional logic.&lt;/p&gt;

&lt;p&gt;In our example, long distance phone numbers will be highlighted &lt;em&gt;(when they begin with "1-")&lt;/em&gt;.  This is accomplished by conditional logic in the html-snippet:&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;i&lt;/span&gt; &lt;span class="na"&gt;class:long-distance=&lt;/span&gt;&lt;span class="s"&gt;{phone.startsWith('1-')}&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  ... snip snip
&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issue here is that Svelte will re-execute the html-snippet based on whether the dependent &lt;code&gt;phone&lt;/code&gt; changes, irrespective of whether the CSS class will change.&lt;/p&gt;

&lt;p&gt;You can see this in the demo by changing the latter part of the phone number (keeping the prefix intact):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m5jBDGmE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ycz0lttcxh65rypk80xm.png" class="article-body-image-wrapper"&gt;&lt;img alt="Long distance NOT changed, but still re-fired" src="https://res.cloudinary.com/practicaldev/image/fetch/s--m5jBDGmE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ycz0lttcxh65rypk80xm.png" width="527" height="699"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, this resulted in a higher number of &lt;strong&gt;reflection counts&lt;/strong&gt; &lt;em&gt;(Svelte's execution of html-snippets)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If we were to move this logical condition into a code-snippet, the resulting html-snippet would result in fewer executions!&lt;/p&gt;

&lt;h4&gt;
  
  
  Takeaway: Fine Tune conditional logic by moving html-snippet variations into code-snippets
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;By allowing conditional expressions to be resolved in a code-snippet, the resulting html-snippet will fire less often.&lt;/p&gt;

&lt;p&gt;This is really an application of the Extreme Optimization: Prefer reactivity in code-snippets verses html-snippets.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here is our &lt;code&gt;GreetUser&lt;/code&gt; component with the applied change:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GreetUser.svelte&lt;/strong&gt; &lt;em&gt;(see &lt;code&gt;GU5_variations.svelte&lt;/code&gt; in &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt;)&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;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
 &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;user&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;./user.js&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;createReflectiveCounter&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;./createReflectiveCounter.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;// normalize our referenced state with primitive types&lt;/span&gt;
 &lt;span class="c1"&gt;// ... html-snippets will only fire when values actually change&lt;/span&gt;
 &lt;span class="c1"&gt;// ... using JS identity semantics&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="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

 &lt;span class="c1"&gt;// FOCUS: with variations in code&lt;/span&gt;
 &lt;span class="c1"&gt;// by allowing conditional expressions to be resolved in a code-snippet,&lt;/span&gt;
 &lt;span class="c1"&gt;// the resulting html-snippet will fire less often.&lt;/span&gt;
 &lt;span class="nl"&gt;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;classes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1-&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;long-distance&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="p"&gt;;&lt;/span&gt;

 &lt;span class="c1"&gt;// diagnostic probes monitoring reflection&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;probe1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&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  section fired&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;probe2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone class   fired&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;probe3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReflectiveCounter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Phone section fired&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;hr/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;Greet User &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;(with variations in code)&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/mark&amp;gt;&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$probe1}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;
  Hello {probe1.monitor() || name}!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;{$probe2}/{$probe3}:&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt;
  May we call you at:
  &lt;span class="nt"&gt;&amp;lt;i&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"{probe2.monitor() || classes}"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    {probe3.monitor() || phone}
  &lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;?
&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
 &lt;span class="nc"&gt;.long-distance&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;pink&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can run this version of the &lt;a href="https://svelte.dev/repl/1385ee3b3ca64f8db38c12404df3e6ca?version=3.24.0"&gt;Demo REPL&lt;/a&gt; by selecting: with variations in code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Bu4ciY34--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eduo8c5m75pyfyyjep7l.png" class="article-body-image-wrapper"&gt;&lt;img alt="Long distance NOT changed, NO re-fire ... FIXED" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Bu4ciY34--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eduo8c5m75pyfyyjep7l.png" width="526" height="699"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Great&lt;/strong&gt;: Notice that the &lt;strong&gt;reflection counts&lt;/strong&gt; &lt;em&gt;(Svelte's execution of html-snippets)&lt;/em&gt; now correctly reflects whether the CSS class actually changed!&lt;/p&gt;

&lt;p&gt;In this rendition, the variability is now accomplished in the component code-snippet:&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;$&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;classes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1-&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;long-distance&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a result, the html-snippet will only execute when the &lt;code&gt;classes&lt;/code&gt; variable actually changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optimization Caveats
&lt;/h2&gt;

&lt;p&gt;Here are a couple of "extras" to consider regarding optimization:&lt;/p&gt;

&lt;h4&gt;
  
  
  Insight: Optimization is only relevant when reactivity occurs for active components
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;The initial render of a component &lt;em&gt;(i.e. when it is mounted)&lt;/em&gt; will unconditionally execute all it's html-snippets &lt;em&gt;(regardless of dependencies, or conditionals)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If there is no reactivity after this, then there is no need to be concerned with these optimization techniques.&lt;/p&gt;

&lt;p&gt;Keep in mind however, that reactivity can sometimes be difficult to predict.  In addition, future revisions to your code may introduce reactivity.  &lt;strong&gt;So be careful!&lt;/strong&gt; It doesn't hurt to always follow these techniques.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Insight: Optimization is preferred but optional
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;If you neglect to follow these optimization techniques, your app will still work correctly.  It just won't be as performant as it could be.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Extra Credit Exercise
&lt;/h2&gt;

&lt;p&gt;For those who would like some &lt;strong&gt;extra credit&lt;/strong&gt;, let me propose an enhancement to our &lt;code&gt;ReflectiveCounter&lt;/code&gt; &lt;em&gt;(discussed in Advanced Diagnostics)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;In it's current form, the &lt;code&gt;ReflectiveCounter&lt;/code&gt; is providing us a &lt;strong&gt;reflexive count&lt;/strong&gt; &lt;em&gt;(the html-snippet execution count)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Can you think of a way that it could provide both &lt;strong&gt;reflexive counts&lt;/strong&gt; -and- &lt;strong&gt;re-render counts&lt;/strong&gt; &lt;em&gt;(that is ... of the DOM updates)&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;This little exercise should &lt;em&gt;&lt;strong&gt;separate the Geeks from the wannabes&lt;/strong&gt;&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;I won't give you the solution directly, but here is a &lt;strong&gt;very big hint&lt;/strong&gt; ...  The invocation will change:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FROM:&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;i&amp;gt;&lt;/span&gt;{fooProbe.monitor() || $foo}&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;TO:&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;i&amp;gt;&lt;/span&gt;{fooProbe.monitor( () =&amp;gt; $foo )}&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Are you up for the challenge?&lt;/strong&gt; FYI: There is a hidden easter egg &lt;em&gt;(tucked away somewhere)&lt;/em&gt; that reveals the solution!  If you can't find it, just &lt;strong&gt;ping me in the comments below&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who is this guy?
&lt;/h2&gt;

&lt;p&gt;Just to give you a little of my background &lt;em&gt;(as it relates to software engineering)&lt;/em&gt;...&lt;/p&gt;

&lt;p&gt;I have been in the software industry for over 40 years.  I'm probably the &lt;strong&gt;old guy in the room&lt;/strong&gt; &lt;em&gt;(retired since 2015)&lt;/em&gt;.  I like to say that &lt;em&gt;&lt;strong&gt;I am a "current" developer from a different era&lt;/strong&gt;&lt;/em&gt;, but gee whiz, it is getting harder and harder to stay current!  Case in point: &lt;em&gt;I'm just now learning Svelte, which has been out &lt;strong&gt;how long&lt;/strong&gt;&lt;/em&gt;?&lt;/p&gt;

&lt;p&gt;Needless to say, I cut my "programming teeth" 25 years before there was a usable internet &lt;em&gt;(in the mid 70's)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I remember the great computing pioneer, &lt;a href="https://en.wikipedia.org/wiki/Grace_Hopper"&gt;Grace Hopper&lt;/a&gt; as a visiting lecturer, who at the age 73 imparted the computing insights of the day &lt;em&gt;(which at it's core, wasn't all that different from today)&lt;/em&gt;.  She used great visual aids ...  &lt;strong&gt;passing out &lt;a href="https://americanhistory.si.edu/collections/search/object/nmah_692464"&gt;nanoseconds&lt;/a&gt;&lt;/strong&gt;, etc.  Admiral Hopper was a senior way back then &lt;em&gt;(in the mid 70's)&lt;/em&gt;, so I suppose I shouldn't be too self conscious :-) &lt;strong&gt;Trivia point&lt;/strong&gt;: &lt;em&gt;she also coined the term: &lt;strong&gt;&lt;a href="https://www.atlasobscura.com/places/grace-hoppers-bug"&gt;bug&lt;/a&gt;&lt;/strong&gt;&lt;/em&gt;!&lt;/p&gt;

&lt;p&gt;When I eventually started web-development &lt;em&gt;(in the mid 90's)&lt;/em&gt;, I was "all in" for this new &lt;a href="https://en.wikipedia.org/wiki/Netscape"&gt;Netscape&lt;/a&gt; technology called JavaScript!  Even back then, we were providing reactivity at a page level, using this new innovation.&lt;/p&gt;

&lt;p&gt;Over the years I have written a number of large-scaled SPAs &lt;em&gt;(predating the SPA term)&lt;/em&gt;, using pure JavaScript &lt;em&gt;(i.e. there were no frameworks)&lt;/em&gt;!  Believe me, providing large-scaled app-based reactivity is a daunting task, requiring some good underlying architecture, and ultimately a lot of code!&lt;/p&gt;

&lt;p&gt;I actually skipped right over the jQuery phenomenon, and went straight into the new declarative frameworks ... first Angular, then React.  This declarative approach never ceases to amaze me ... &lt;em&gt;&lt;strong&gt;in realizing how much can be accomplished with so little code&lt;/strong&gt;&lt;/em&gt; :-)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Svelte merely takes this progression to the next level&lt;/strong&gt;!  It provides all the benefits of a declarative approach, without the bloated in-memory run-time framework!&lt;/p&gt;

&lt;p&gt;I have been contributing to open source since my retirement &lt;em&gt;(in 2015)&lt;/em&gt;.  My most recent offering is a product called &lt;a href="http://bit.ly/feature-u-teaser"&gt;feature-u&lt;/a&gt;: &lt;em&gt;a React utility that facilitates &lt;strong&gt;Feature-Driven Development&lt;/strong&gt;&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;I am a &lt;strong&gt;brand spanking new Svelter&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;My first Svelte project &lt;em&gt;(too early to publish)&lt;/em&gt; is a re-creation of my most prized project &lt;em&gt;(in the early 90's)&lt;/em&gt;.  It was an "Engineering Analysis" tool, written in C++ under Unix/X-Windows.  It had:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;schematic capture: with multiple functional decompositions of the master schematic&lt;/li&gt;
&lt;li&gt;executable control laws: through graphical flow diagrams that were executable&lt;/li&gt;
&lt;li&gt;simulation: driven by the control laws (animating one or more of the schematics and control laws)&lt;/li&gt;
&lt;li&gt;a symbolic debugger: also driven by the control laws&lt;/li&gt;
&lt;li&gt;auto generation of the embedded system code (derived from the executable control laws)&lt;/li&gt;
&lt;li&gt;Needless to say, this system has &lt;strong&gt;reactivity on steroids&lt;/strong&gt;!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find me &lt;a href="https://wiibridges.com"&gt;On The Web&lt;/a&gt;, &lt;a href="https://www.linkedin.com/in/kevinbridges"&gt;LinkedIn&lt;/a&gt;, &lt;a href="https://twitter.com/kevinast"&gt;Twitter&lt;/a&gt;, and &lt;a href="https://github.com/KevinAst"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Well, this turned out to be a much "deeper dive" than what I had initially envisioned :-) We have covered a lot!  I hope you enjoyed this little journey, and learned something as well!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A big thanks&lt;/strong&gt; goes out to &lt;a href="https://twitter.com/Rich_Harris"&gt;Rich Harris&lt;/a&gt; and the &lt;a href="https://github.com/sveltejs/svelte/graphs/contributors"&gt;Core Contributors&lt;/a&gt; for making Svelte such an awesome product!  I can't wait to see what the future holds in the next release!&lt;/p&gt;

&lt;p&gt;Happy Computing,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;/Kevin&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt; For your convenience, I have summarized my findings here.  Each point contains a short synopsis, and is linked to the more comprehensive discussion.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Terminology: snippet, code-snippet, and html-snippet&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Within this article, the term &lt;strong&gt;snippet&lt;/strong&gt; refers to any JavaScript expression that Svelte reactively manages and invokes when it's dependent state changes.&lt;/p&gt;

&lt;p&gt;Snippets may either be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;code-snippets&lt;/strong&gt; &lt;em&gt;(referred to as &lt;strong&gt;Reactive Declarations&lt;/strong&gt; and &lt;strong&gt;Reactive Statements&lt;/strong&gt;)&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;or &lt;strong&gt;html-snippets&lt;/strong&gt; &lt;em&gt;(commonly referred to as &lt;strong&gt;interpolation&lt;/strong&gt;)&lt;/em&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ultimately, snippets provide the dynamics within our html markup &lt;em&gt;(i.e. it's reactivity)&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Insight: Reactivity is based on change in dependent state&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Snippet execution is triggered when dependent state changes&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;primitive types trigger reactivity only when the value changes &lt;em&gt;(based on identity semantics)&lt;/em&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;objects trigger reactivity per the entire object, not individual content&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Takeaway: Monitor Svelte snippet invocations through logically-ORed prefixed expressions&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can detect when Svelte executes a snippet by prefixing it with a &lt;strong&gt;logically-ORed&lt;/strong&gt; monitor.&lt;/p&gt;

&lt;p&gt;This can be a simple logging probe or a more advanced ReflectiveCounter&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Insight: Diagnostic probes are temporary&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Diagnostic probes should be considered temporary, and removed &lt;em&gt;(or commented out)&lt;/em&gt; when your analysis is complete.&lt;/p&gt;

&lt;p&gt;There are techniques where they can be disabled at run-time &lt;em&gt;(with minimal overhead)&lt;/em&gt;, but this exercise is left up to the reader.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Insight: Svelte's reflexivity is very efficient!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The component's DOM representation is highly optimized, broken down into fragments that can be re-built at the lowest level of our DOM tree.&lt;/p&gt;

&lt;p&gt;Dynamic content is gleaned from executing html-snippets.&lt;/p&gt;

&lt;p&gt;Reflection is triggered by dependent state changes.&lt;/p&gt;

&lt;p&gt;DOM updates occur only when the content has actually changed &lt;em&gt;(using a very light-weight string comparison)&lt;/em&gt;!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Extreme Optimization: Prefer reactivity in code-snippets verses html-snippets&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The overhead of &lt;strong&gt;code-snippets&lt;/strong&gt; are typically very light, because they merely change JavaScript state variables.&lt;/p&gt;

&lt;p&gt;While it is true that variable changes can result in html DOM changes &lt;em&gt;(by stimulating a dependent &lt;strong&gt;html-snippet&lt;/strong&gt;)&lt;/em&gt;, this will be canceled out, when the dependent variable is unchanged &lt;em&gt;(within the &lt;strong&gt;code-snippet&lt;/strong&gt;)&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Takeaway: Fine Tune Svelte's Dependency Management by using primitive types&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;When an html-snippet dereferences an object that has the potential of changing (e.g. &lt;code&gt;user.name&lt;/code&gt;), this may result in a false-positive condition.&lt;/p&gt;

&lt;p&gt;Svelte will re-execute the snippet based on whether the top-level object has changed (e.g. &lt;code&gt;user&lt;/code&gt;), and not the dereferenced result!&lt;/p&gt;

&lt;p&gt;You can change this by depending on primitive types &lt;em&gt;normalized from the object (say through a code-snippet)&lt;/em&gt;, giving the html-snippet finer granularity in what triggers it's execution.&lt;/p&gt;

&lt;p&gt;html-snippets that depend on primitive types will only execute when their dependent values change &lt;em&gt;(based on identity semantics)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;This is really an application of the Extreme Optimization: Prefer reactivity in code-snippets verses html-snippets.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Takeaway: Fine Tune conditional logic by moving html-snippet variations into code-snippets&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By allowing conditional expressions to be resolved in a code-snippet, the resulting html-snippet will fire less often.&lt;/p&gt;

&lt;p&gt;This is really an application of the Extreme Optimization: Prefer reactivity in code-snippets verses html-snippets.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Insight: Optimization is only relevant when reactivity occurs for active components&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The initial render of a component &lt;em&gt;(i.e. when it is mounted)&lt;/em&gt; will unconditionally execute all it's html-snippets &lt;em&gt;(regardless of dependencies, or conditionals)&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If there is no reactivity after this, then there is no need to be concerned with these optimization techniques.&lt;/p&gt;

&lt;p&gt;Keep in mind however, that reactivity can sometimes be difficult to predict.  In addition, future revisions to your code may introduce reactivity.  &lt;strong&gt;So be careful!&lt;/strong&gt; It doesn't hurt to always follow these techniques.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Insight: Optimization is preferred but optional&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you neglect to follow these optimization techniques, your app will still work correctly.  It just won't be as performant as it could be.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>svelte</category>
      <category>reactivity</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Create more manageable React applications with Features</title>
      <dc:creator>Kevin Bridges</dc:creator>
      <pubDate>Mon, 06 Jan 2020 22:34:18 +0000</pubDate>
      <link>https://dev.to/kevinast/create-more-manageable-react-applications-with-features-2dai</link>
      <guid>https://dev.to/kevinast/create-more-manageable-react-applications-with-features-2dai</guid>
      <description>&lt;p&gt;Is your &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt; project organized by features? …  &lt;strong&gt;NO?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zimwm1MP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/798/1%2ATLYupudltbA0UBbRyB96PQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zimwm1MP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/798/1%2ATLYupudltbA0UBbRyB96PQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You know, features are where your resources are organized by what they accomplish in your app (i.e. features), rather than lumping all files of like types into one massive blob of components, routes, logic, actions, reducers, selectors, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0UPu4geY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A8GHt18xe1e1tG9VQOXTMRQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0UPu4geY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A8GHt18xe1e1tG9VQOXTMRQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you are using features&lt;/strong&gt; , &lt;em&gt;then consider this&lt;/em&gt; …&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;are your features encapsulated and isolated?&lt;/li&gt;
&lt;li&gt;do your features collaborate in an extendable way?&lt;/li&gt;
&lt;li&gt;are your components using cross-feature composition?&lt;/li&gt;
&lt;li&gt;do your features initialize themselves?&lt;/li&gt;
&lt;li&gt;can you disable features at run-time?&lt;/li&gt;
&lt;li&gt;do your frameworks auto-configure with only active features?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, &lt;strong&gt;do your features plug-and-play? … NO?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I know, I know, &lt;strong&gt;you’re busy&lt;/strong&gt;  … which is great because projects with busy teams &lt;em&gt;can’t become unwieldy&lt;/em&gt; … &lt;strong&gt;OH WAIT&lt;/strong&gt;  … &lt;em&gt;I read that wrong&lt;/em&gt; … &lt;strong&gt;THEY CAN!&lt;/strong&gt; &lt;em&gt;(I should have worn my glasses)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1YYZY1-1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/560/1%2A4bQkKW1Hzq5oSYIfIhOrVQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1YYZY1-1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/560/1%2A4bQkKW1Hzq5oSYIfIhOrVQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s cut to the chase:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your not using features - &lt;strong&gt;YOU SHOULD!&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;If your features aren’t based on &lt;a href="https://feature-u.js.org/"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt; - &lt;strong&gt;THEY SHOULD BE!&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://feature-u.js.org/"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt; is a utility that facilitates feature-based development in your &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt; project. It provides tangible assistance in promoting individual &lt;strong&gt;plug-and-play&lt;/strong&gt; features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G295CVnR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AzYzt9w49KV-TCbuUMD_Ieg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G295CVnR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AzYzt9w49KV-TCbuUMD_Ieg.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a number of benefits in using &lt;a href="https://feature-u.js.org/"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt;, but the two fundamental ones are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A formal means by which features can collaborate with one another, making them truly &lt;strong&gt;plug-and-play&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A significant reduction in boilerplate code by automatically configuring your frameworks and startup initialization.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The following diagram summarizes &lt;strong&gt;feature-u&lt;/strong&gt; ’s basic concepts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RPeKUpoa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AqsohsNr9SgLca22xW6r1eQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RPeKUpoa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AqsohsNr9SgLca22xW6r1eQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Feature Collaboration is accomplished by:&lt;/em&gt;&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Introducing a formal means by which features can collaborate with one another (&lt;a href="https://feature-u.js.org/cur/crossCommunication.html"&gt;Cross Feature Communication&lt;/a&gt;), making them truly &lt;strong&gt;plug-and-play&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This includes the ability for &lt;a href="https://feature-u.js.org/cur/crossCommunication.html#ui-composition"&gt;UI Composition&lt;/a&gt; to cross feature boundaries. It even allows UI Content to be injected autonomously. &lt;em&gt;This is something that has to be seen …&lt;/em&gt; &lt;strong&gt;&lt;em&gt;it shows off the utility very well&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;&lt;em&gt;A significant reduction in boilerplate code is accomplished through:&lt;/em&gt;&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Auto configuration of your frameworks (using &lt;a href="https://feature-u.js.org/cur/extending.html"&gt;plugable extensions&lt;/a&gt;), and&lt;/li&gt;
&lt;li&gt;Allowing features to initialize themselves (through &lt;a href="https://feature-u.js.org/cur/appLifeCycle.html"&gt;Application Life Cycle Hooks&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Features can be disabled
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;through a &lt;a href="https://feature-u.js.org/cur/enablement.html"&gt;Feature Enablement&lt;/a&gt; run-time switch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This foundation forms the basis of why&lt;/em&gt; &lt;strong&gt;&lt;em&gt;feature-u&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;was developed, and manifests itself into a&lt;/em&gt; &lt;a href="https://feature-u.js.org/cur/why.html"&gt;&lt;em&gt;number of benefits&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://feature-u.js.org/"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt; is the utility you didn’t know you needed, but subsequently can’t live without! It opens new doors into the exciting world of feature-based development and frees you up to focus your attention on the “business end” of your features!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F7tddP1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/347/1%2Au3DlVwpWCIriyzTZXEslJg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F7tddP1Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/347/1%2Au3DlVwpWCIriyzTZXEslJg.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learn more about &lt;strong&gt;feature-u&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://feature-u.js.org/"&gt;docs&lt;/a&gt; - comprehensive &lt;strong&gt;feature-u&lt;/strong&gt; documentation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://feature-u.js.org/cur/presentation.html"&gt;presentation&lt;/a&gt; - a &lt;strong&gt;feature-u&lt;/strong&gt; presentation video to get you started &lt;strong&gt;(a must see)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://feature-u.js.org/cur/concepts.html"&gt;basic concepts&lt;/a&gt; - a full introduction to &lt;strong&gt;feature-u&lt;/strong&gt; concepts and terminology &lt;strong&gt;(a must read)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/KevinAst/eatery-nod-w"&gt;eatery-nod-w&lt;/a&gt; - a sample web app using &lt;strong&gt;feature-u&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/KevinAst/feature-u"&gt;repo&lt;/a&gt; - &lt;strong&gt;feature-u&lt;/strong&gt; source&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>features</category>
      <category>fdd</category>
    </item>
    <item>
      <title>Are you using features?</title>
      <dc:creator>Kevin Bridges</dc:creator>
      <pubDate>Wed, 26 Dec 2018 18:23:36 +0000</pubDate>
      <link>https://dev.to/kevinast/are-you-using-features-7nm</link>
      <guid>https://dev.to/kevinast/are-you-using-features-7nm</guid>
      <description>&lt;p&gt;Is your &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt; project organized by features? …  &lt;strong&gt;NO?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F798%2F1%2ATLYupudltbA0UBbRyB96PQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F798%2F1%2ATLYupudltbA0UBbRyB96PQ.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You know, features are where your resources are organized by what they accomplish in your app (i.e. features), rather than lumping all files of like types into one massive blob of components, routes, logic, actions, reducers, selectors, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A8GHt18xe1e1tG9VQOXTMRQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A8GHt18xe1e1tG9VQOXTMRQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you are using features&lt;/strong&gt; , &lt;em&gt;then consider this&lt;/em&gt; …&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;are your features encapsulated and isolated?&lt;/li&gt;
&lt;li&gt;do your features collaborate in an extendable way?&lt;/li&gt;
&lt;li&gt;are your components using cross-feature composition?&lt;/li&gt;
&lt;li&gt;do your features initialize themselves?&lt;/li&gt;
&lt;li&gt;can you disable features at run-time?&lt;/li&gt;
&lt;li&gt;do your frameworks auto-configure with only active features?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, &lt;strong&gt;do your features plug-and-play? … NO?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I know, I know, &lt;strong&gt;you’re busy&lt;/strong&gt;  … which is great because projects with busy teams &lt;em&gt;can’t become unwieldy&lt;/em&gt; … &lt;strong&gt;OH WAIT&lt;/strong&gt;  … &lt;em&gt;I read that wrong&lt;/em&gt; … &lt;strong&gt;THEY CAN!&lt;/strong&gt; &lt;em&gt;(I should have worn my glasses)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F560%2F1%2A4bQkKW1Hzq5oSYIfIhOrVQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F560%2F1%2A4bQkKW1Hzq5oSYIfIhOrVQ.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s cut to the chase:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your not using features - &lt;strong&gt;YOU SHOULD!&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;If your features aren’t based on &lt;a href="https://feature-u.js.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt; - &lt;strong&gt;THEY SHOULD BE!&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://feature-u.js.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt; is a utility that facilitates feature-based development in your &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt; project. It provides tangible assistance in promoting individual &lt;strong&gt;plug-and-play&lt;/strong&gt; features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AzYzt9w49KV-TCbuUMD_Ieg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AzYzt9w49KV-TCbuUMD_Ieg.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a number of benefits in using &lt;a href="https://feature-u.js.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt;, but the two fundamental ones are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A formal means by which features can collaborate with one another, making them truly &lt;strong&gt;plug-and-play&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;A significant reduction in boilerplate code by automatically configuring your frameworks and startup initialization.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The following diagram summarizes &lt;strong&gt;feature-u&lt;/strong&gt; ’s basic concepts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AqsohsNr9SgLca22xW6r1eQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AqsohsNr9SgLca22xW6r1eQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;&lt;em&gt;Feature Collaboration is accomplished by:&lt;/em&gt;&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Introducing a formal means by which features can collaborate with one another (&lt;a href="https://feature-u.js.org/cur/crossCommunication.html" rel="noopener noreferrer"&gt;Cross Feature Communication&lt;/a&gt;), making them truly &lt;strong&gt;plug-and-play&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This includes the ability for &lt;a href="https://feature-u.js.org/cur/crossCommunication.html#ui-composition" rel="noopener noreferrer"&gt;UI Composition&lt;/a&gt; to cross feature boundaries. It even allows UI Content to be injected autonomously. &lt;em&gt;This is something that has to be seen …&lt;/em&gt; &lt;strong&gt;&lt;em&gt;it shows off the utility very well&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;&lt;em&gt;A significant reduction in boilerplate code is accomplished through:&lt;/em&gt;&lt;/strong&gt;
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Auto configuration of your frameworks (using &lt;a href="https://feature-u.js.org/cur/extending.html" rel="noopener noreferrer"&gt;plugable extensions&lt;/a&gt;), and&lt;/li&gt;
&lt;li&gt;Allowing features to initialize themselves (through &lt;a href="https://feature-u.js.org/cur/appLifeCycle.html" rel="noopener noreferrer"&gt;Application Life Cycle Hooks&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Features can be disabled
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;through a &lt;a href="https://feature-u.js.org/cur/enablement.html" rel="noopener noreferrer"&gt;Feature Enablement&lt;/a&gt; run-time switch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This foundation forms the basis of why&lt;/em&gt; &lt;strong&gt;&lt;em&gt;feature-u&lt;/em&gt;&lt;/strong&gt; &lt;em&gt;was developed, and manifests itself into a&lt;/em&gt; &lt;a href="https://feature-u.js.org/cur/why.html" rel="noopener noreferrer"&gt;&lt;em&gt;number of benefits&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://feature-u.js.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;feature-u&lt;/strong&gt;&lt;/a&gt; is the utility you didn’t know you needed, but subsequently can’t live without! It opens new doors into the exciting world of feature-based development and frees you up to focus your attention on the “business end” of your features!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F347%2F1%2Au3DlVwpWCIriyzTZXEslJg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F347%2F1%2Au3DlVwpWCIriyzTZXEslJg.jpeg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Learn more about &lt;strong&gt;feature-u&lt;/strong&gt; :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://feature-u.js.org/" rel="noopener noreferrer"&gt;docs&lt;/a&gt; - comprehensive &lt;strong&gt;feature-u&lt;/strong&gt; documentation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://feature-u.js.org/cur/presentation.html" rel="noopener noreferrer"&gt;presentation&lt;/a&gt; - a &lt;strong&gt;feature-u&lt;/strong&gt; presentation video to get you started &lt;strong&gt;(a must see)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://feature-u.js.org/cur/concepts.html" rel="noopener noreferrer"&gt;basic concepts&lt;/a&gt; - a full introduction to &lt;strong&gt;feature-u&lt;/strong&gt; concepts and terminology &lt;strong&gt;(a must read)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/KevinAst/eatery-nod-w" rel="noopener noreferrer"&gt;eatery-nod-w&lt;/a&gt; - a sample web app using &lt;strong&gt;feature-u&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/KevinAst/feature-u" rel="noopener noreferrer"&gt;repo&lt;/a&gt; - &lt;strong&gt;feature-u&lt;/strong&gt; source&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>libraries</category>
      <category>react</category>
      <category>features</category>
    </item>
  </channel>
</rss>
