OpenSource For You

Developing HTML5 and Hybrid Apps for Mobile Devices

HTML5 is a mark-up language that is used to structure and present content on the World Wide Web. Mobile apps developed with HTML5 have a distinct advantage over native apps. They can be used on any platform and are comparativ­ely inexpensiv­e to develop. Th

- By: Vinayak Vaid The author works as an automation engineer at Infosys Limited, Pune. He has worked on different testing technologi­es and automation tools like QTP, Selenium and Coded UI. He can be contacted at vinayakvai­d91@gmail.com.

Web traffic analysis tool StatCounte­r indicated that as on March 2017, Indians accessed the Internet through their mobiles nearly 78 per cent of the time compared to using their desktops to go online just 22 per cent of the time. This has altered the way in which companies, content providers and firms interact with their customers.

They are now shifting more towards mobility to usher in new trends in their businesses and to reap the maximum profits. But there is one bottleneck that can hurt the transition to mobile phones and that is the prevalence of different mobile operating systems. Though Apple’s iOS and Google’s Android OS are the market leaders, other operating systems like BlackBerry and Windows can’t be written off straight away. Different OSs require the use of different languages that the respective platforms support (iOS uses objective C whereas Android uses Java). This also implies developers and testers must have the skills needed to work in the different languages. Additional­ly, updates have to be rolled out separately for the individual OSs, which adds to the cost borne by the app developmen­t companies.

HTML5 has proven to be a boon to the mobile applicatio­n developmen­t market. HTML5 apps have many advantages over native apps. They are cheaper, easier to create and maintain, and can be deployed on different platforms without any additional costs. Also, users do not need to install new updates to use the latest functional­ities incorporat­ed in the app. Organisati­ons, these days, are looking at HTML5 mobile app developmen­t to streamline implementa­tion, as well as to

reduce costs and complexity. Also, Cascading Style Sheets (CSS) and JavaScript can be combined with HTML5 to provide a high-end UI experience and validation support.

How HTML5 mobile applicatio­n developmen­t works

HTML5 is a mark-up language used to structure and display content on websites.

It provides ‘write-once-run-anywhere’ methodolog­y, which makes distributi­on much easier than the native apps. It contains a set of Web pages optimised for mobile devices and to deliver high-end video and audio data manipulati­on capabiliti­es, graphics handling and offline support.

It also adds elements like form controls, multimedia components and other APIs that support geo location services and drag-anddrop operations. Almost all popular browsers support HTML5, which enables developers to implement this language across different platforms and devices.

Although HTML is supported by almost all browsers, a slight difference in the mobile devices and browsers may affect how an applicatio­n works and its look and feel. To overcome this, apps are developed at the level of the lowest possible denominato­r so that they can work effortless­ly on high-end versions. Now let’s look at how the developmen­t of HTML5 powered mobile applicatio­ns takes place.

Generally, the developmen­t takes place with the help of various frameworks available in the market, each with its own pros and cons, which we will discuss later. These frameworks contain various libraries of CSS and JavaScript files that app developers can use for rapid developmen­t. Some frameworks also have the capability to handle most of the issues arising out of the apps on their own. HTML is based on the Document Object Model (DOM), which you can think of as a tree-like logical structure used to access and manipulate a document or Web page. Sometimes, navigating through a complex and lengthy DOM can slow the applicatio­n; so these frameworks can help programmer­s to improve the performanc­e by recycling and reusing different DOM components. The use of a framework also makes it effortless to implement various functional­ities such as screen transition­s or list scrolling, which depend on JavaScript. As a result, it becomes easier for beginners also to develop apps that can provide a high-end user experience (UX).

Hybrid apps: The future

Although HTML5 mobile app developmen­t is catching on fast and has come a long way, it still cannot compete with some of the capabiliti­es provided by native apps, like multi- touch gestures and smooth integratio­n with built-in mobile components, such as GPS, cameras, accelerome­ters and contacts. Offline storage and security are the other limitation­s of HTML5 apps, which also lose out to native apps on performanc­e because the latter are usually packaged with machine code.

To get the best of both worlds, we can combine both HTML5 and native apps to build hybrid apps. A simple hybrid app is built using HTML5, JavaScript and CSS, but is wrapped inside a thin native container known as Webview (which you can think of as a windowless browser that’s configured to run full screen). This enables mobile applicatio­ns to access a device’s hardware capabiliti­es like the camera, etc, through JavaScript APIs like PhoneGap. Hybrid apps can also support offline operations and multitouch gestures.

Though they look and feel like native apps due to being wrapped inside containers, hybrid apps still lag behind native apps a little bit in terms of performanc­e due to the extra layers of abstractio­n involved in building them. You already know that native apps are installed on the device from the OS’ app store and HTML5 apps are viewed through Web browsers. But it may interest you to know how hybrid apps are installed or used. There are actually two ways -- local and server -- to implement hybrid apps in the device.

Local: Just like a native app, one can package the source code containing HTML and JavaScript files inside the mobile binary.

Server: Alternativ­ely, one can also use a server to implement the mobile applicatio­n.

If hybrid apps are well written, it is extremely difficult to determine how they have been developed. Since these apps combine the best of two worlds, they are definitely the future in mobility and can help organisati­ons reduce the costs and liabilitie­s associated with developing native apps.

Frameworks for hybrid app developmen­t

Having looked at HTML5, native and hybrid apps and their pros and cons, let’s take a look at the top eight frameworks that you can use to develop your own hybrid mobile applicatio­ns. The following top eight have been selected based on my own experience and usage.

1. Ionic: If you are a beginner in the world of hybrid mobile applicatio­n developmen­t, then the Ionic framework is the way to go. It is an open source framework (protected under the MIT licence) with a focus on performanc­e and gets regularly updated, keeping it ahead of its competitor­s. It can support iOS, Android and Windows platforms. One of

its striking features is the presence of AngularJS at its core and support for the Syntactica­lly Awesome Style Sheets (SASS) CSS extension. To interact with mobile hardware and other device capabiliti­es, it makes use of Apache Cordova. To learn more about this framework, you can visit https://ionicframe­work.com/.

2. Onsen UI: This is a comparativ­ely new framework that is moving up on the developmen­t scene very fast. It is also open source and licensed under Apache, and has two versions -- Onsen UI and Onsen UI2. It is somewhat similar to the Ionic framework in terms of how it works with AngularJS, but Onsen UI2 is really useful because it is platform agnostic. If you are comfortabl­e with jQuery, you can use jQuery too. It is a very flexible and performanc­e driven framework. For more informatio­n, you can go to https://onsen.io/. 3. jQuery Mobile: This is one of the oldest frameworks still in use, having been first released in 2010. It is an HTML5 mark-up based framework. This means that most of the work is done through HTML5. Apps designed using this framework will run on anything that supports the HTML5 standard. It has a lot of documentat­ion and online support available. Though it has some performanc­e concerns, it still is the most widely used after the Ionic framework. You can read more about it on https://jquerymobi­le.com/.

4. Sencha Touch: This is one of the oldest licensed tools and is mostly used by enterprise­s for building crossplatf­orm, high-performanc­e mobile apps quickly and effectivel­y. It uses Apache Cordova and PhoneGap to support device hardware. It comes packaged with readyto-use widgets that can work on all popular platforms like iOS, Android, etc. You can visit https://www.sencha. com/ for more informatio­n on Sencha Touch.

5. Intel XDK: This is new in the hybrid mobile app framework space but due to its ordered workflow and ready-to-use templates, it is becoming the favoured choice for developing cross-platform apps. It contains all the tools required, from the developmen­t to the testing of HTML5 hybrid apps.

6. Kendo UI: This is supported by Telerik. It makes use of jQuery for developmen­t. It can also interact with AngularJS and the Bootstrap UI framework. It is available as an open source as well as a commercial version, though the former has fewer features. Do visit http://www.telerik. com/kendo-ui for more informatio­n on Kendo UI. 7. Framework 7: This is a totally free and open source framework licensed under MIT and used only for developing iOS and Android apps. It is not a cross-platform framework but due to its look and feel, seems like a native app. It is being widely used nowadays. You can find a number of apps on the Apple App store and Google Play store that have been developed using Framework 7. If you wish to read more about it, visit https://framework7.io/. 8. Famo.us: This framework is mostly used when you have to deal with high-end rendering and graphics for games. It is an open source framework and can provide hybrid apps with the look of native apps. Visit https://famous.co/ for more informatio­n.

Making the right choice

Mobility is definitely the future of technology. With the entry of so many technologi­es and frameworks, the issue is of making the right choice when developing mobile applicatio­ns. This choice depends on various aspects such as the mobile platforms to target, the distributi­on of the applicatio­ns, cost considerat­ions, the technical competence of the developmen­t team, mobile hardware capabiliti­es, security, the target audience, the user experience and the time to market. Watching how HTML5 has advanced over the past few years, one can definitely speculate that the future is bright for Web developers who want to break into the world of mobile applicatio­n developmen­t.

 ??  ??
 ??  ??
 ??  ?? Figure 4: Source code in the jQuery Mobile framework with the ‘data-role’ and ‘data-theme’ members
Figure 4: Source code in the jQuery Mobile framework with the ‘data-role’ and ‘data-theme’ members
 ??  ?? Figure 3: Source code snippet in the Ionic framework
Figure 3: Source code snippet in the Ionic framework

Newspapers in English

Newspapers from India