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 2 to 1

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.

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
— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews