The long tagline on the cover of Shane Gliser’s new book deftly sums up its contents: “Learn to make practical, unique, real-world sites that span a variety of industries and technologies with the world’s most popular mobile development library.”
Gliser unabashedly describes himself as a jQuery “fanboy…if it’s officially jQuery, I love it.” He is an experienced mobile developer and blogger who operates Roughly Brilliant Digital Studios. He also has some background in mobile UX (user experience).
Both aspects of that background serve him well in his smoothly written, nicely illustrated how-to book that zeroes in on jQuery Mobile, a “touch-optimized” web framework for smartphones and tablets.
You may be surprised when you extract the 234-page book’s code examples and related items and find that the ZIP file is almost 100MB in size. Gliser covers a lot of ground in his 10 chapters. And each chapter contains a project.
Still, what you don’t do in the first chapter, “Prototyping jQuery Mobile,” is work at a computer. In the true spirit of UX, Gliser has you start first with a pen and some 3×5 note cards. Your goal is to rough out some designs for a jQuery Mobile website for a new pizzeria.
Why the ancient technology? “We are more willing to simply throw out a drawing that took less than 30 seconds to create,” Gliser writes. Otherwise, it’s too easy to stay locked into one design while trying different ways to make its code work. And: “Actually sketching by hand uses a different part of the brain and unlocks our creative centers.”
Best of all, working first with paper sketches enables team members who are not coders to contribute some comments, suggestions, and corrections for the emerging design.
In Chapter 2, “A Mom-and-Pop Mobile Website,” you step over to your computer with the paper prototype in hand and start converting the final design “into an actual jQuery Mobile (jQM) site that acts responsively and looks unique.” You also begin building “a configurable server-side PHP template,” and you work with custom fonts, page curl effects using CSS, and other aspects of creating and optimizing a mobile site.
“Mobile is a very unforgiving environment,” Gliser cautions, “and some of the tips in this section will make more difference than any of the ‘best coding practices.’” Indeed, he wants you to be aware of optimization “at the beginning. You are going to do some awesome work and I don’t want you or your stakeholders to think it’s any less awesome, or slow, or anything else because you didn’t know the tricks to squeeze the most performance out of your systems. It’s never too early to impress people with the performance of your creations.”
Chapter 3, “Analytics, Long forms, and Front-end Validation,” moves beyond “dynamically link[ing] directly into the native GPS systems of iOS and Android.” Instead, Gliser introduces how to work with Google static maps, Google Analytics, long and multi-page forms, and jQuery Validate. As for static maps, he says, “Remember to always approach things from the user’s perspective. It’s not always about doing the coolest thing we can.” Indeed, a static map may be all the user needs to decide whether to drive to a business, such as a pizzeria, or just call for delivery. And, as for Google Analytics: “Every website should have analytics. If not, it’s difficult to say how many people are hitting your site, if we’re getting people through our conversion funnels, or what pages are causing people to leave our site.”
Meanwhile, desktop users are familiar with (and frequently irritated by) long forms and multi-page forms. Lengthy forms can be real deal-breakers for users trying to negotiate them on mobile devices. The author presents some ways to shorten long forms and break them “into several pages using jQuery Mobile.” And he emphasizes the importance of using the jQuery Validate plug-in to add validation to any page that has a form, so the user can see quickly and clearly that an entry has a problem.
The focus in Chapter 4, “QR Codes, Geolocation, Google Maps API, and HTML5 Video,” is on handling concepts that can be “applied to any business that has multiple physical locations.” Gliser uses a local movie theater chain as his development example. A site is created that makes use of QR codes, geolocation, Google Maps, and linking to YouTube movie previews. Then, he shows how to use embedded video to keep users on the movie chain’s site rather than sending them off to YouTube.
In Chapter 5, the goal is “to create an aggregating news site based off social media.” So the emphasis shifts to “Client-side Templating, JSON APIs, and HTML5 Web Storage.” Notes Gliser: “Honestly, from a purely pragmatic perspective, I believe that the template is the perfect place for code. The more flexible, the better. JSON holds the data and the templates are used to transform it. To draw a parallel, XML is the data format and XSL templates are used to transform. Nobody whines about logic in XSL; so I don’t see why it should be a problem in JS templates.”
Next, he shows how to patch into Twitter’s JSON API to get “the very latest set of trending topics” and “whittle down the response to only the part we want…and pass that array into JsRender for…well…rendering” in a manner that will be “a lot cleaner to read and maintain” than looping through JSON and using string concatenation to make the output.
Other topics in Chapter 5 include programmatically changing pages in jQuery Mobile, understanding how jQuery Mobile handles generated pages and Document Object Model (DOM) weight management, and working with RSS feeds. Gliser points out that there is still “a lot more information out there being fed by RSS feeds than by JSON feeds.” The chapter concludes with looks at how to use HTML5 web storage (it’s simple, yet it can get “especially tricky on mobile browsers”), and how to leverage the Google Feed API. Says Gliser: “The Google Feeds [sic] API can be fed several options, but at its core, it’s a way to specify an RSS or ATOM feed and get back a JSON representation.”
Chapter 6 jumps into “the music scene. We’re going to take the jQuery Mobile interface and turn it into a media player, artist showcase, and information hub that can be saved to people’s home screens,” Gliser writes. He proceeds to show how “ridiculously simple it can be to bring audio into your jQuery Mobile pages.” And he explains how to use HTML5 manifest “and a few other meta tags” to save an app to the home screen. Furthermore, he discusses how to test mobile sites using “Google Chrome (since its WebKit) or IE9 (for the Windows Phone)” as browsers that are shrunken down to mobile size. “Naturally, this does not substitute for real testing,” he cautions. “Always check your creations on real devices. That being said, the shrunken browser approach will usually get you 97.5 percent of the way there. Well…HTML5 Audio throws that operating model right out the window.”
Since “mobile phones are quickly becoming our photo albums,” Gliser’s Chapter 7, “Fully Responsive Photography,” shows first how to create a basic gallery using Photoswipe. Then, in a section focused on “supporting the full range of device sizes,” he explains how to start using responsive web design (RWD), “the concept of making a single page work for every device size.” The issues, of course, range from image sizes and resolutions to text sizes and character counts per line, on screens as small as smart phones and tablets, or larger.
As for mobilizing full-site pages “the hard way,” he states that there is really “only one good reason: to keep the content on the same page so that the user doesn’t have one page for mobile and one page for desktop. When emails and tweets and such are flying around, the user generally doesn’t care if they’re sending out the mobile view or the desktop view and they shouldn’t.” He focuses on how “it’s pretty easy to tell what parts of a site would translate to mobile” and how to add data attributes to existing tags “to mobilize them. When jQuery’s libraries are not present on the page, these attributes will simply sit there and cause no harm. Then you can use one of our many detection techniques to decide when to throw the jQM libraries in.”
Mobilizing full-size pages “the easy way” involves, in his view, “nothing easier and cleaner than just creating a standalone jQuery Mobile page…and simply import the page we want with AJAX. We can then pull out the parts we want and leave the rest.” His code samples show how to do this.
Chapter 9, “Content Management Systems and jQM” looks at the pros and cons of using three different content management systems (CMS) with jQuery Mobile: WordPress, Drupal, and Adobe Experience Manager. “The key to get up and running quickly with any CMS is, realizing which plugins and themes to use,” Gliser writes. He also explains how to use mobile theme switchers.
Drupal offers some standard plugins that provide contact forms, CAPTCHA, and custom database tables and forms, and enable you to “create full blown web apps, not just brochureware sites,” he notes. But: “The biggest downside to Drupal is that it has a bit of a learning curve if you want to tap its true power, Also, without some tuning, it can be a little slow and can really bloat your page’s code.” .
As for Adobe Experience Manager (AEM), Gliser merely introduces it as a “premier corporate CMS” and a “major CMS player that comes with complete jQuery Mobile examples.” He doesn’t show “how to install, configure, or code for AEM. That’s a subject for several training manuals the size of this book.”
Chapter 10, the final chapter, is titled “Putting It All Together — Flood.FM.” Using what you’ve learned in the book (including prototyping the interfaces on paper first), you create “a website where listeners will be greeted with music from local, independent bands across several genres and geographic regions.” Along the way, Gliser introduces Balsamiq, “a very popular UX tool for rapid prototyping.” He discusses using Model-View-Controller (MVC), Model-View-ViewModel (MVVM), and Model-View-Whatever (MV*) development structures with jQuery Mobile. He shows how to work with the Web Audio API , and he illustrates how to prompt users to download the Flood.FM app to their home screens. He finishes up with brief discussions of accelerometers, cameras, “APIs on the horizon,” plus “To app or not to app, that is the question” and whether you should compile an app or not. Finally, he shows PhoneGap Build, the “cloud-based build service for PhoneGap.”
Bottom line: Shane Gliser’s book covers a lot of useful ground for those who are ready to learn jQuery Mobile.
– Si Dunn