BartOtten

BartOtten

Phoenix Live Head

HTML Head manipulation for Phoenix Live

Provides commands for manipulating the HTML Head of Phoenix Live View applications while minimizing data over the wire.

The available command actions support a variety of utility operations useful for HTML Head manipulation. Such as setting or removing tag attributes and adding or removing CSS classes.

A special feature is the use of the {dynamic} tag in values. This saves data over the wire by only sending the dynamic part of an attributes value.

DO NOT USE THIS LIB…

..would for sure draw your attention. This lib is rather low-level. When you use it, consider publishing a convenience lib with higher-level functions or request one in this topic. Data minimization rules can be added to this lib on request.

Convenience libs currently available:

Showcase / Tryout / Demo

There is an example app available for inspection. This example app is using the higher-level Phoenix Live Favicon which depends on Phoenix Live Head.

Data minimization

The lib minimizes data over the wire to make sure it can be used in low bandwidth conditions and for very large scale apps. Those few bytes of most head changes might not look like a large payload but when you have a low bandwidth connection or 2 million clients in one chat room* every byte counts.

So this lib:

  • merges head events per element
  • substitutes some known element- and attribute names
  • provides the {dynamic} placeholder

As a result this is the information for updating 2 favicon links (32x32 and 16x16):

  • reset all favicon attributes to their initial values (reset)
  • set {dynamic} placeholder in href-attributes of all favicons to ‘green’
  • set class-name of all favicons to ‘green’
# 84% reduction! (54 bytes instead of 335 bytes).
  "hd", {
	"f": ["i", ["d", "h", "green"], ["s", "c","green"]]
     }
]

As a result the favicons change from:

<link  rel="icon" sizes="32x32" class="custom" href="images/some/completely/different-32x32.png">
<link  rel="icon" sizes="16x16" class="custom" href="images/some/completely/different-16x16.png">

to

<link  rel="icon" sizes="32x32" class="green" href="images/green/favicon-32x32.png">
<link  rel="icon" sizes="16x16" class="green" href="images/green/favicon-16x16.png">

Links

Hex
Hexdocs
Github
Search forum for tag

* 2 million clients in one chatroom

Showing Posts 1 to 2

BartOtten

BartOtten OP

v0.1.2

Discards previous changes put in events for given element or attribute when using reset.

  • Fix: preserve event order
  • Fix: predictable behavior when using reset/1 or reset/2.
  • Fix: undefined class name after reset
BartOtten

BartOtten OP

Release 0.3.0
A small one, on demand :slight_smile:

The new function push_content makes a call to update the textContent property and not an attribute.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 15444 137
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
261 13183 112
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
charlenopires
Hi everyone :waving_hand: I’ve been working on PhiaUI, an open-source UI component library for Phoenix LiveView, and I wanted to share i...
New

Other Trending Topics Top

OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
mat-hek
Popcorn, the library that runs Elixir code in the browser, is now stable :popcorn: This is possible because it now builds on a very stab...
New
bartblast
If you haven’t tried Hologram yet, what’s stopped you? Here’s why I’m asking. Building a framework turns out to be two jobs, the framewo...
New
gtcode
I’ve been tinkering with Lynx (by José) via hold_ledger. I used AI to write the code, a separate specification, the tests, and the Lean p...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews