E Ottaviani Aragão Blog Projetos Sobre Mim

Jails 5 — The latest version and the Front-end state

Jails 5 — Codename Athena — Goddess of Wisdom — Illustration from 3dtotal.com

That's it, another version of this project that started in 2014. Looking at the begining of this project many things changed but the main purpose still exactly the same.

It was built to be a one layer above jQuery concerns, it was all about how to think about logic and component relationship and create a common code structure without breaking the web, making it as close as possible to the Web Development standards keeping the things we already learned, it was not meant to be revolutionary, it was all about to be a progressive enhancement.

Lessons learned from other versions

  1. Nobody will write simple code just using Jails, there's a need to find a time to help on education with this library. I thought that because it's simpler, the applications would be simpler aswell, but it turns out to be not true in practice.
  2. JS community still has room to grow, I thought everything I ever needed would be available in some sort of javascript open source library. It seems that it's not that true, only morphdomused in this project was mature enought and keeping updated. There are several good projects out there that are being abandoned or lacks motivation to keep it up.
  3. Rendering is the most complicated thing to be 100% complete. There's a lot of edge corners and it's quite challenging to be aware of them and I believe this is the most important part of Component libraries and frameworks.

What changed in this last version?

Template system

Technically a lot of stuff. But the main issue that was haunting me was the fact that a child component wasn't able to see variables created in template system context, it was impossible to pass down a variable from a iteration for child components. That was fixed but changing the way I was working with morphdom plus I had to replace the good soda template system for a new one more flexible.

Core System

I always do a rewrite from scratch in major versions, that because as programmers we do evolve our way to abstract things and we are always getting better at it. So there's a lot of improvement in logic which might not be a huge difference for final users but it does help me to keep it more reasonable so it's easier to add more features in a more elegant way, also less bugs that happens due to a bad code construction.

In this process of rewritting I just realized that I was managing lifecycle manually and it seems that Custom Element api is already there in the majority of the browsers, so I was iluminated by this idea:

What if I use the Custom Element define api ? It already has a native lifecycle for a html element and it would be more close to the web standards in a way that Jails component now would be a custom element instead of a regular html element with some data-component on it…

That worked like a charm… I was removing code from the source, keeping it more simple, more reasonable and more elegant. Plus it can be used as a web component. Great!

The current state of Web Development

Jails was always about keeping your js code separated from your html, it's was all about separation of concerns, It was all about keeping things simple.

But some of the best ideas and learnings was that kept us away from dangerous development was being replaced in the name of revolutionary ideas from modern Frameworks. Perhaps a lot of things was lost in this process:

  1. Performance and SEO was degrated from past years brought by SPA idea, and now is a thing that most of new ideas are trying to bring back those concerns.
    Those issues were never in Jails concerns because I aways bet on separation of concerns and that means Javascript for behavior, other languages for rendering.
  2. Complexity. Most of the time you'll see more code and more frameworks dialects to solve the exactly the same problems we used to have 10/12 years ago but more complex: Redux, Redux Saga, useMemo, useCallback, and the list goes on… Maybe we're going to far…

Jails is still in the right way…

There are new ideas emerging nowadays. There are not 100% new, but they bring some new technics from modern apps in order to let the good old ideas more digestible.

Those ideas are bringing back the best practices we learned in the past:

  1. Multipages instead of Single Page Application for Fast pages and SEO complient.
  2. To choose static pages generation whenever its possible so you can antecipate errors in build time, save money with hosting.
  3. Jamstack. Keeping the business logic centered in Api's so you can separate your front-end repository and keep it decoupled from back-end development, so you can write front-end with any framework you want.
  4. Monorepo. There's now a trend that tells you that sometimes it's better to keep everything in just one place for simplicity sake, and now there are some tools in order to help you with that, also yarn and npm already give you a native way to manage your dependencies in a single project.
  5. Island Architecture. The idea that javascript behavior is added in a restricted area of your page instead of mounting it on entire app. That Island Architecture strategy may help you to decrease your bundle size and your application complexity.

All those things was already in Jails philosophy, I was working with this library in several production apps and some of the modern headaches I never had to face.

It seems that Jails is, just like a good book, something that shows its true value along the years.

Thank you.


Jails 5 — The latest version and the Front-end state. was originally published in Jails-org on Medium, where people are continuing the conversation by highlighting and responding to this story.