top | item 35930089

(no title)

evadne | 2 years ago

Phoenix LiveView uses JS because the core of the tech requires the server to compute diffs & the client to patch the DOM accordingly. This is why a JS package is needed alongside the other default package from Phoenix, which brings Phoenix Sockets & Channels capability (which builds on top of transports such as Websocket).

Previously have seen: https://github.com/patrick-steele-idem/morphdom

Can check: https://www.npmjs.com/package/phoenix_live_view

discuss

order

johnisgood|2 years ago

For anyone wondering, this is where I complain about Phoenix being bloated[1], and others have informed me that "There’s no JavaScript unless you write it into the template.", and that I can reduce the bloat in this way: "You pass the `--no-assets` flag when using `mix phx.new`"[2]

I do not know how true it is today.

[1] https://news.ycombinator.com/item?id=31317545

[2] https://hexdocs.pm/phoenix/Mix.Tasks.Phx.New.html

ricketycricket|2 years ago

As one of those others, I can confirm this is indeed still true as of Phoenix 1.7. `--no-assets` will not add any CSS or JS to the project other than empty `app.js` and `app.css` files in `/priv/static/assets` for you to fill in yourself if you want. You are completely on your own to implement an asset pipeline of your choosing. Of course, if you want LiveView you will have to bring some JS back in.

di4na|2 years ago

It depends what you do. If all you want is http requests and assets, no js needed. Being html or api.

If you want to handle a websocket and have a 2 way bindings, then no way around it. But that is not phoenix fault. It is the reality of the browsers api. It is pretty minimal js though.