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 Announcing Top

Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Thank...
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
mspanc
I am pleased to announce an initial release of the Membrane Framework - an Elixir-based framework with special focus on processing multim...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 30338 241
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10789 141
New
kip
ex_cldr provides localisation and internationalisation support based upon the data from the Unicode CLDR project. Unicode released CLDR ...
407 13256 120
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 11220 107
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement