BartOtten

BartOtten

Phoenix Live Head - HTML Head manipulation for Phoenix Live

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

Most Liked

BartOtten

BartOtten

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.

Where Next?

Popular in Libraries Top

josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 13801 100
New
arkgil
Hi all! I’m happy to announce that Telemetry v0.3.0 is out! This release marks the conversion from Elixir to Erlang so that all the libr...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
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
riverrun
I’ve just released version 3 of Comeonin, a password hashing library. The following small changes have been made: changes to the NIF c...
New
Jskalc
Hi! Today, after a couple weeks of development I’ve released v0.1 of LiveVue. It’s a seamless integration of Vue and Phoenix LiveView, i...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. Most of the changes are around JavaScript interop now that Elixirscript uses the ...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

Sub Categories:

We're in Beta

About us Mission Statement