dojap

dojap

Which JavaScript framework do you prefer to use with Phoenix?

When you have to use one, which do you prefer and why?

React or Vue, or something else?

Most Liked

dorgan

dorgan

I’ve used pretty much all of them, though not for too large projects. My personal conclusion is that, unless you have some specific product that requires a feature that only one of these offer, then it doesn’t really matter.

For the most part, except maybe for Angular(and maybe Ember?) they’re view libraries, so they’re just a templating system and some reactivity system to trigger view updates when data changes.

React and Vue have large ecosystems. Vue has always been a bit lighter(if we count react + react_dom) than react, but really it’s not that important. I’ve fiddled with React and Vue 2, I built a somewhat big Vue SPA, there’s nothing particularly weird about them(except the react hooks rules). Vuex was a pain in the ass, because at the time I didn’t really understand the problem it solved and everybody was hyping redux like stores. Lesson learned there. They both performed very badly in my low end phone. I’m not 100% sure if it was because of the framework or because of my mistakes, but switching to custom elements and doing stuff myself solved it for the most part.

Svelte has a compiler to “optimize” the code and “reduce bundle size” and “gain speed”. The truth is that not using a Virtual DOM approach is not a benefit per se, libraries like Inferno use VDOM and perform better in a lot of cases. Bundle size is amortized for small projects, but if you have lots of components then the promise of “vanishing js framework” starts to break. It’s fast and excellent, but not the fastest. Still for a lot of use cases I’m unsure if this is a useful benchmark.

Solid is another library that recently reached v1.0, it’s compiled as Svelte, but faster, and Ryan(the author) is a very nice person. The api is very similar to react hooks, but the reactive system is far better. If you know the Meiosis pattern or RxJS, it has similar ideas. If I were to use one today, I would probably pick Solid, because of Ryan and because it uses similar ideas to the ones I’ve been playing with in the past.

Marko is a framework by the Ebay people, it’s able to do SSR, streaming and a lot of the stuff React now presents as shiny new but since 2014. I’m very interested in it but didn’t have the chance to use it.

Then you have the Browser, you can use the Custom Elements API and write components that render using something like Lit or uhtml, but this is more of a DIY approach. I love this approach, but I understand some people just want to use a full blown framework.

I’d love to give a recommendation but after using a lot of them I realised that the complexity comes from building UIs, not so much from the frameworks themselves. People have built awesome stuff with all of them.

17
Post #3
code-shoily

code-shoily

I very roughly explained the process here: ClojureScript + LiveView - Backend Chat/Discussions - Devtalk but once I get to work more on this and address some rough edges, I will write a better looking post about it.

tl;dr

A PR that documents the process - https://github.com/code-shoily/miles_to_go/pull/2/
A repository with LiveView hooks with ClojureScript (widgets: Line Charts, Pie Charts and Heatmap via PlotlyJS) - GitHub - code-shoily/covid19: A Phoenix app to display Novel Coronavirus (COVID-19) · GitHub

superchris

superchris

Thanks for the shout out :slight_smile: We’ve used LiveView and Web Components together now on several projects and it’s worked out very well. In my humble opinion, it’s a perfect fit. Live View is great at managing DOM Elements, and since Custom Elements are still just DOM Elements at the end of the day, it makes a nice boundary to add in javascript when it is the best solution to a specific problem.

Last Post!

olafura

olafura

Really love how easy it’s to use Lit for frontend, easy to debug since it’s just the dom and you can just inspect an element and run functions.

It also allows for real separation of concerns between Phoenix and Liveview and the JavaScript part.

Where Next?

Popular in Discussions Top

mbenatti
Following https://github.com/tbrand/which_is_the_fastest |> https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
restack_oslo
Hello, Please pardon me for any faux paux. I am 46 and this is my first time on a forum of any kind. I wanted to to get answers from tho...
New
und0ck3d
Hello everyone! A few days ago I’ve created a topic here about how people were creating CMSs with Elixir and Phoenix. I’ve been studying...
New
Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
Rustixir
Hi everyone, im working on find best language/framework/system for high concurrency, high performance and stable performance after wor...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
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
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New

We're in Beta

About us Mission Statement