News for hackers. Stuff that matters.
Re:Tetra – Full stack reactive component framework for Djang... by samwillis on Friday May 27, 2022 @08:31AM (#31528794)
I have a blog post in the works to go into depth the thoughts about this.

The gist though (copied from the introduction):

--

Proximity of related concerns is as important as separation of concerns. Whilst it is important to keep your backend logic, front end JavaScript, HTML, and styles separate, it is also incredibly useful to have related code in close proximity.

Front end toolkits such as Vue.js, with its single file components and newer "utility class" based CSS frameworks such as Tailwind, have shown that keeping related aspects of a component in the same file helps to reduce code rot, and to improve the speed at which developers gain an understanding of the component.

--

Really the intention is that you can keep small parts of CSS/JS close to where it is being used. Larger functionality, particularly anything reused, you would still break out into separate files.

The creator of htmx refers to this as "Locality of Behaviour", they wrote a good post on it (https://htmx.org/essays/locality-of-behaviour/)

There are no comments on this comment yet.