mercredi 21 octobre 2015

Back to Standards

I’m not so much a front-end guy. I mean, I do love hacking CSS and JS for the browser, but I don’t do it that much as a pro to be aware of all the best practices in this domain. And JS being the top class citizen in the Web this day, this field earned a huge complexity within a blink and I feel a bit overwhelmed. I’m still nicely editing my JS and CSS, refreshing the browser to see the results at the time of preprocessing, transpiling and minifying megabytes of code.

I often wonder if it doesn’t go too far sometimes, to the point that programmers need to reimplement a behavior brought for free by the browser. The must funny example is the use of the prev and next buttons in one page app. But you can also reimplement every form input elements.

That’s what I did, in a project I decided to replace input fields and buttons by plain divs. Because I found that contenteditable attribute was cool. I believed it’ll be easier to style everything.
I realized my mistake lately as getting all in place was a PITA. Moreover, now that I use vimperator, I found out that it would be awful to use the app without mouse if I did not recode the whole shit by myself. So I brought back my text areas and buttons tags. I just “unstyled” them and rework my JS a little bit. I was done in less than a hour.

So here’s the lesson. If you are not a professional front end developer and you need to get things done quickly, consider these points:

  • Keep it stupid simple. Really. Rely on what is offered by the browser. Do not try to be smart because this front end thing is waaaay too complicated for you.
  • It’s hard to admit this because I hate it… But use JQuery as it will eliminate a lot of burden. Coding in vanilla js when you have DOM manipulation is fun until you realize you spend hours to fix a simple UI behavior. And you’ll need few days more to make your fix cross browsers.
  • Really consider to use UI boilerplates like Foundation or Bootstrap. They’re blazingly simple to put in place, provide an elegant look and feel and make your site responsive for free. I know you see the same UI everywhere on the Internet. That’s because the other developers and startupers are like you: they lack skills and time and yet, need to get things done quickly.

This post raises the question of the choice between learning things deeply and get side projects done and be proud of them (where proud can mean getting money). It’ll be a great topic for another post.