Thinking Elixir News 145 Elixir Security: Sobelow 0.12.1 Released, Adds LiveView Support

Phoenix LiveView's new JS.exec/3 function!

Phoenix 1.7.2 shipped a new JS.exec/3 function.

It allows us to execute JS defined in a different dom element.

Why would we want that?

If we’re repeating the same code in multiple places (e.g. hide modal), even if we’re using a helper function to reduce code duplication, we might still be sending that several times in the payload!

JS.exec/3 allows us to reduce that payload by only including the JS command in a single place!

Here I refactor a modal component 👉 https://youtu.be/fZd58xxY4pU 👀