---
title: "💭 </> htmx ~ Locality of Behaviour (LoB)"
description: "!https://htmx.org/essays/locality-of-behaviour/"
date: 2023-10-28
published: true
tags:
  - htmx
  - webdev
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://htmx.org/essays/locality-of-behaviour/" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-content">
      <div class="embed-card-title">&lt;/&gt; htmx ~ Locality of Behaviour (LoB)</div>
      <div class="embed-card-description">Carson Gross explores the Locality of Behaviour (LoB) principle, which emphasizes making the behavior of code units obvious on inspection to enhance maintainability. He discusses the tradeoffs betw...</div>
      <div class="embed-card-meta">htmx.org</div>
    </div>
  </a>
</div>


Interesting principle here.  What a great example, If I'm looking at the second jQuery example, I have to dig into dev tools or make some assumtions that this team uses jQuery, and selects by id, therefore I can grep for `$("#d1")`.

> Consider two different implementations of an AJAX request in HTML, the first in htmx:
``` heml
<button hx-get="/clicked">Click Me</button>


> and the second in jQuery:

``` js
  $("#d1").on("click", function(){
    $.ajax({
         /* AJAX options... */
    });
  });
```
``` html
<button id="d1">Click Me</button>
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
