---
title: "</> htmx ~ Locality of Behaviour (LoB)"
description: "!https://htmx.org/essays/locality-of-behaviour/"
date: 2023-10-28
published: true
tags:
  - dev
  - htmx
  - thought
  - webdev
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>
```
