Refactoring our frontend development stack

At Code Yellow we write frontend heavy apps. This means that the browser is responsible for all the rendering, and the backend only handles API requests. In the last few weeks we have been busy refactoring a large part of our backend, frontend and development workflow to ensure the best technologies available are used. In this article I want to highlight the changes we made to our frontend stack. As such, this article is intended for frontend developers.

Passing variables from server to client using RequireJS

It’s quite common to pass variables from server to client. Common uses are bootstrapping data, syncing config setting etc. Consider the following scenario: a single page app where a user logs in and refreshes the current page. You want the user to still be logged in. The most commonly used practise is to put it in a script tag: <script type="text/javascript"> var userId = 1; </script> This way you introduce a global variable userId.

Coding style guide

Introduction The 2 most used languages at Code Yellow are PHP Javascript PHP has PHP-FIG which is becoming more commenly accepted. Javascript has idiomatic. For all projects we apply these rules: General First check: PSR-1 PSR-2 Use single quotes for strings where possible: PHP $stringA = ‘this is a string’; $stringB = ‘this is another string ’ . $blah . ‘ test’; Javascript var stringA = ‘this is a string’, stringB = ‘this is a string ’ + blah + ‘ test’; First start with properties, then functions.