Under the hood: How we build Hoiio Apps
Over the last 2 months, we have launched 3 apps on our portal:
- Main Line: a virtual PBX or a main number of any business
- Conference: a convenient way to setup conference call
- Fax: online fax system for business
As we launch more apps on Hoiio Platform over the next few weeks, we want to make sure our users will experience the highest quality of apps.
Today, we have completed testing a new version of Conference app that’s much faster, and more reliable than ever before. To understand how we achieved this, let’s take a look at how Hoiio has evolved on web application development.
Google Web Toolkit (GWT)
We have been using GWT in most of our products, from the user portal to our internal admin dashboard. We have built arrays of custom components that can be reused in any GWT project, making GWT the framework that every web project would start with in Hoiio. Our Apps are no exception. We started developing our apps using GWT and reused a number of major components to speed up the development process. However, we started to feel long in the tooth when feature creep sets in. We also felt the sluggishness of GWT. And as GWT is improved, some of our components and plugins were less relevant in new projects. In light of this, our new Conference app marks our first release without GWT.
Spring + jQuery
Our topmost priority is to ensure that regardless of device, platform or region, Hoiio users will have the best experience in accesing and using our Apps. For each app, we aim for simplicity, ease of use, reliability as well as efficiency of the apps. Yet, the very critical problem that we want to solve is speed. We know that it’s certainly not nice to let our users wait for more than 5 seconds to load an app. At that point, we believed native Javascript is the way to go, and we made a bold move, switching from GWT to a different stack: jQuery on client side and Spring framework on server side.
GWT tightly couples the server side and client side, which means any changes on the client side technology results in a complete rewrite of our app; adopting jQuery and Spring makes client and server side loosely coupled. This means if we, for some reasons, want to adopt another technology in server side, we can easily modify the server side’s code, expose the same sets of APIs to client side, and that’s it.
Main Line was the first app to use this architecture. The result was very positive: app loads faster, our users are happier, and our developers feel that’s the right way to craft our apps. Now, as our apps are gaining more users, and we are receiving positive feedbacks, our next focus are speedy maintenance and upgrade. And that is when we faced an issue that many Javascript developers considered a nightmare: managing Javascript.
Managing Javascript: The issues we are facing
The first problem we got with handcoding Javascript is maintaining states of the views. Right now, it’s rather easy to create great web applications with jQuery. However, our apps are constantly growing, making jQuery declarations and callbacks more complex, and are distributed all over the place. The code becomes more cluttered and hard to read.
The second problem is managing events for DOM elements. In fact, we already experienced the frustration on binding events to the spaghetti code mess that we had created at earlier time. For example, the first version of Conference app has around 15 events, 4 different types of data objects that interact with each other, and many DOM elements that depend on each other in certain ways like CSS effects. We feel that without a proper structure, we will soon face a lot of issues while maintaining our app.
Another problem we are experiencing is mixing HTML code inside Javascript. A good example is when retrieving data to fill a table, there are a lot of append() calls inside javascript. We think this is not a good approach.
BackboneJS, HandlebarsJS and RequireJS
We consider ourselves latecomer in adopting BackboneJS’s great technology. At a glance, BackboneJS gives us a tool to structure our client side code, allowing us to modularly organize our Javascript code so that it’s much easier to maintain and upgrade. It also provides an event-driven communication between views and models, in which events can be attached to any attribute of a model that gives us control over what we change in the view. BackboneJS alone solved most of our problems, and with HandlebarsJS templating engine, most, if not all, of our Javascript problems are solved.
RequireJS, on another hand, helps us further split BackboneJS’s module into separate Javascript files for ease in development. Now, for example, a User model will be located at user.js file, a Phonebook model will be located at phonebook.js file. This is very important to us as we can finally structure our client code in a very nice way.
The disadvantage in our approach is multiple Javascript files, which leads to multiple requests needed when serving our apps’ contents. Therefore, we further optimize our app using r.js: an optimizer for RequireJS which combine all our javacript into 1 javascript file and minified it, allowing for even faster response time. Now, whenever we develop, all modules are clearly defined and separated in many javascript files. Once we’re ready for deployment, our users will see only 1 highly optimized and minified javascript.
The fact: Speed comparison
We measure the speed of our app to demonstrate the performance gain we have achieved. Test machine is in Vietnam, server is in US. Same app is used during testing
Using GWT
First request (no cache) takes 13.6 seconds to complete.
Second request (with cache) takes 2 seconds to complete.
Using BackboneJS + RequireJS
First request (no cache) takes 3.6 second to complete.
Second request (with cache) takes 1 seconds to complete.
The results say it all. BackboneJS and RequireJS beat GWT in every ways: 4x faster without cache and 2x with cache.
Coming soon. For all apps.
We are committed to deliver quality apps. That’s why at Hoiio, we never stop to research the latest technologies that helps to create the best user experience. Conference app is now ready to deploy, and we are starting to make all other apps faster. Stay tuned.














