What is your favourite JS library for the UI front-end?

That is indeed true, but something that gets mitigated by loading less JS and less CSS in each request (and also by internet speed). Having a clean, non-bloated design that does not use fancy JS for effects and what have you, is in my opinion, a better experience (it also makes the page easy to navigate by screen readers for people with disabilities).

Another advantage to this approach is that the initial load of the page does not have to load all your JS framework code and your own code in order to run, which will make the initial load really slow. Subsequent loads will be cached, but stillā€¦

1 Like

Then use a javascript shim. :slight_smile:

Something like unpoly is such a shim, it loads pages from the server async then swaps the needed parts in the DOM, it is quick, still all server-side rendered, you can even add transitions and more. :slight_smile:

/me uses a lot of unpoly.js, wishes it was module-based though, but eh

6 Likes

Phoenix is fast, that time delay effect of page transitions is not a big deal compared to all that needs to be cared for using a complete VueJS solution on the front-end: state store, routing etcā€¦ no to mention webpack and npm and as you have said the possibly huge JS file that needs to be loaded on first visit.

How big is your js file with vuejs? The last time I used it, it was prettry small, about 50kb gzipped, and it included router, vuex, vue, and my application.

And downloading 50kb is hardly noticeable unless you are on a modem (http://www.download-time.com says itā€™d take 7 seconds)ā€¦

Right now though Iā€™m looking into preact, which, together with a router and redux, fits in 10kb.

1 Like

Have you encountered any limitation with Phoenix on API backend and VueJS on UI? Have you implemented user authentication on that setup?

Have you encountered any limitation with Phoenix on API backend and VueJS on UI?

No, but if I were doing it again, I would probably use graphql for talking to the backend. VueJS was nice for UI, I really liked its styled components.

I might even use a different setup in the future, with cowboy websockets (or something of my own) for app logic and nginx for sending out js chunks from webpack. That would make the website extra fast, I guess. And scaling extra hard.

Have you implemented user authentication on that setup?

Yes, I sent a phoenix token to the client and stored it there. And then included it with every request in the Authorization header as a Bearer token.

1 Like

Have you used re:dom with large aplications ?

Not yet, Iā€™m currently working on my web serviceā€™s frontend with RE:DOM but it wonā€™t be a single page application, but rather it will be used to enhance some places, to draw graphs and stuff. Iā€™m still quite new with it so donā€™t yet have good rules how to organise stuff. But the smaller things I have made with it have worked well and it has been fun to write.

It seems like all the preferences are geared towards landing/info page sites.

What about full on Facebook / Gmail / Forums / CRM type web-apps?

How they have front-end user experiences and full on admin specific user experiences that are completely different. With all kinds of users in different companies, where there are all kinds of views depending on the action of the current user. Adding/removing features based on users or group memberships etc

I like the Ember.js framework ideology. My biggest annoyance with these frontend frameworks is the all or nothing part. If someone loads up the signup page, they donā€™t need the admin app or the full logged in user part yet, even if they are logged in, there needs to be a balance between first response and quick 2nd page. Ember has engines finally to help with this.

On a page by page basis I like the simplicity of other frameworks/libraries, however to get some efficiency across the whole app, spending time making components inside a full framework and stitching them together in the page as needed has been great. For example with a simple information game (think rpg, clan, army kinds), while the REST way was fine every single resource on its own page works it was super slow to get anything done. I needed lots of information from many endpoints on the page in their own little space on the screen and they all needed to update based on actions happening in the backend.

This is where I see a full framework like Ember.js being a great fit. If I were building a landing page/informational product site Iā€™d go pure HTML with a helper if needed to make something appear instantly responsive to actions.

2 Likes

Iā€™ve been working with mithriljs for more than a year now. Thats super cool, easy to use and fast. Recommended!!

3 Likes

Couldnā€™t agree more. While I have no special love for JS, when i do need to use it, I use VanillaJS wherever possible.

2 Likes

Can you point me in the direction to learning more about using JS shims?

I would suggest Ember.js. Itā€™s fast, easy to learn, has a great tooling story (ember-cli) and can be easily extended through addons (see Ember Observer for existing addons).

The post mentions Unpoly specifically which has a tutorial.

In terms of terminology it is interesting to note that people often use the term ā€œshimā€ when they mean ā€œpolyfillā€ (What is the difference between a shim and a polyfill? - i.e. not every shim is polyfill) - Unpoly isnā€™t polyfill (unless itā€™s poly-filling ā€œitā€™s own imaginary standardā€). The creatorā€™s tagline:

Itā€™s not you, Itā€™s Us
Weā€™re Breaking Up With JavaScript Frontends
Henning Koch, makandra GmbH
@triskweline

http://triskweline.de/unpoly-rugb/#/

https://twitter.com/triskweline/status/841779063933026308

3 Likes

Thanks for that, I really appreciate it. I have some playing around to do now :slight_smile: