title: Switch slider (using a checkbox) is flickering with AJAX "back" history
body: <p>The following code queries a <code>state.json</code> file on load and updates the slider switch. It uses <code>fetch(...)</code>. It works.</p>
  <p>When clicking on the text &quot;Click on this text...&quot;, the top <code>div</code> is replaced by another text with HTMX.</p>
  <p><strong>Problem</strong>: when clicking browser &quot;Back&quot; button, <strong>the switch slider moves again (flickering)</strong>, and it should not: only the div <code>#me</code> should be modified by HTMX, not the rest.</p>
  <p><strong>Question: how to avoid the switch to flicker when doing history Back?</strong> (even if we remove the CSS transition, we still have a very fast flickering).</p>
  <p>Live demo <a href="http://5.135.181.77/test-Uls9z2gryn9h/Gqy341uccmn7/" rel="nofollow noreferrer">here</a>.</p>
  <p><code>index.php</code></p>
  <pre><code>&lt;script src=&quot;https://unpkg.com/htmx.org@1.8.0&quot;&gt;&lt;/script&gt;
  &lt;style&gt;
  .switch { appearance: none; height: 30px; width: 52px; background-image: linear-gradient(to bottom, transparent 0 22px, dodgerBlue 22px), linear-gradient(to right, white 0 22px, dodgerBlue 22px 60px); background-position: 4px 4px; }
  .switch { transition: 0.2s; }
  .switch:checked { background-position: 26px 4px; }
  &lt;/style&gt;
  &lt;div hx-get=&quot;page2.txt&quot; hx-push-url=&quot;true&quot; id=&quot;me&quot;&gt;Click on this text to go to next page&lt;/div&gt;
  &lt;input type=&quot;checkbox&quot; id=&quot;checkbox&quot; class=&quot;switch&quot;&gt;
  &lt;script&gt;
  fetch(&quot;state.json&quot;).then(r =&gt; r.json()).then(data =&gt; {
      document.getElementById(&quot;checkbox&quot;).checked = data['state'] == 'checked';
  });
  &lt;/script&gt;
  </code></pre>
  <p><code>page2.txt</code></p>
  <pre><code>Hello, now click on the &quot;Back&quot; history button of your browser.
  </code></pre>
  <p><code>state.json</code></p>
  <pre><code>{&quot;state&quot;: &quot;checked&quot;}
  </code></pre>