Preface

In your pocket is a device that has changed the lives of billions of people all over the world. The third personal screen (after the TV and the computer) is the most personal one, and bringing our services to it is one of the key business priorities of this decade.

Mobile development, however, is a more challenging activity than desktop development. Platforms are severely fragmented, and developers have to work with minimal resources. Fortunately, the mobile web makes it easier to deal with this fragmentation, allowing developers to create applications that run on many more platforms than native (or installable) applications. As we will see later, the mobile web and installable applications are not enemies. In fact, they work together very well.

All of that sounds great: billions of devices, web technologies, multiplatform solutions... where’s the problem? More than half of your desktop web skills and the tips, hacks, and best practices you already know simply do not apply on the mobile web. The mobile web demands new usability patterns, new programming best practices, and new knowledge and abilities.

This is a second edition, prepared two years after the first one. At the time of the first edition there were almost no books, websites, or training courses focused on concrete mobile web programming. Today it’s more common to find such information; however, it’s not always good enough. We don’t need vague information like “this may not work on some phones”; we need real, fresh, and working data. On which devices does a solution not work? Why? Is there another solution? That is why I’ve written this book: to help developers in programming mobile websites.

You may feel that you are advanced enough to go directly to the code, but I encourage you to start from the beginning of the book if you are new to the mobile world. This is another universe, and every universe has its own rules.

Who This Book Is For

This book is for experienced web developers who want to learn what’s different about designing for the mobile web. We will talk about HTML, CSS, JavaScript, Ajax, and server-side code as if you have experience with all those technologies. If you are a web designer with some basic programming skills, you will also find this book useful.

We will cover HTML5 features, but don’t worry if you don’t have any experience with this platform yet; we will cover it from the ground up, and your HTML 4 and XHTML 1.0 knowledge will be enough.

If you are an individual freelancer, if you work for a company in the areas of programming or web development, or if you work in a web design studio, this book is for you. Perhaps you need to create a mobile application or client for a current desktop service, you want to add new services to your portfolio, or you need to migrate an old mobile website to newer devices.

You may also be a web entrepreneur with—or looking for—a great idea for mobile devices, and you want to analyze what you can do with current mobile browsers. This book investigates compatibility device by device and discusses advanced features you can implement.

The book will also be useful if you are wondering how to identify devices and deliver proper and compatible content for ad campaigns, to sell content or to deliver free content to mobile users.

Who This Book Is Not For

I don’t really want to cut anyone out of the possibility of reading this book, but there are a lot of people who aren’t likely to benefit from all of it. If you are a graphic designer, you will not find detailed tips and practices in this book, and you are likely to enjoy only the first four chapters.

If you are a web designer without programming skills, Chapter 1 through Chapter 7 are the ones you should read line by line; the rest will be useful to review so you know the capabilities you can request from a developer.

If you are a native mobile developer (iPhone, Android, Java mobile, Windows Phone), some web knowledge will be required in order to understand and follow all the samples in this book.

This is also not a book for learning basic HTML, CSS, or JavaScript. You will not find detailed samples or step-by-step instructions on how to implement every task. It is assumed that you are experienced enough to create code on your own, or at least know how to find out by searching the Web.

If you are a manager, a CTO, a project leader, or an entrepreneur without any web knowledge, you will find the first four chapters useful: they describe the current state of the art in this market and should help you decide how to organize your team.

What You’ll Learn

This book is an advanced reference for the mobile web today, and it is the most complete reference available at this time. This may seem an ambitious claim, but it is the truth. This book draws upon a mix of experience and very detailed research and testing not available in other books, websites, or research papers about the mobile web.

Programming the Mobile Web will teach you how to create effective and rich experiences for mobile web browsers, and also how to create native web applications that will be installed in a device’s applications menu.

We will not talk only about the star devices, like the iPhone and Android devices; we will also cover mass-market platforms from Nokia, BlackBerry, Amazon, Microsoft, and other vendors.

Other Options

The main challenge looking for books and online resources is finding solutions that contain information, not ones having plenty of “maybes,” “perhapses,” and “be carefuls.”

If you need to learn web technologies, there are plenty of books and resources available. Take a look at oreilly.com/css-html and oreilly.com/javascript for some lists.

If you want a complement to this book in the areas of design, performance, and advanced programming, I recommend the following books:

If You Like (or Don’t Like) This Book

If you like—or don’t like—this book, by all means, please let people know. Amazon reviews are one popular way to share your happiness (or lack of happiness), and you can leave reviews on this book’s website.

There’s also a link to errata there, which readers can use to let us know about typos, errors, and other problems with the book. Reported errors will be visible on the page immediately, and we’ll confirm them after checking them out. O’Reilly can also fix errata in future printings of the book and on Safari, making for a better reader experience pretty quickly.

We hope to keep this book updated for future mobile platforms, and will also incorporate suggestions and complaints into future editions.

Conventions Used in This Book

The following font conventions are used in this book:

Italic

Indicates pathnames, filenames, and program names; Internet addresses, such as domain names and URLs; and new items where they are defined.

Constant width

Indicates command lines and options that should be typed verbatim; names and keywords in programs, including method names, variable names, and class names; and HTML/XHTML element tags.

Constant width bold

Used for emphasis in program code lines.

Constant width italic

Indicates text that should be replaced with user-supplied values.

Note

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

Using Code Examples

This book is here to help you get your job done. In general, if this book includes code examples, you may use the code in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: "Programming the Mobile Web, Second Edition by Maximiliano Firtman (O’Reilly). Copyright 2013 Maximiliano Firtman, 978-1-449-33497-0.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/program_mobile_web_2e.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

I want to thank first all the members of my family, including my parents, Stella Maris and Edgardo, my brother, Sebastián, and my lovely wife, Ani, who have supported me during the writing of this book and all of my projects.

Second, thanks to the many people who have helped with comments, reviews, and criticisms on the first edition of this book and on the many training courses and conferences I’ve held since its publishing. Without them, I could not have learned as much as I have and gained experience in this minefield.

I want to thank my technical reviewers, who helped find some bugs and fill in some information gaps: Tomomi Imura, Carlos Solís, Dion Almaer, Luca Passani, and Edgar Parada.

A special thanks to Vivian Cromwell, Alejandro Villanueva, Nick Bortolotti, Fernando Freytes, John Koch, Robert Burdick, Adam Stanley, and Bryan Tafel for their support.

A special mention to Rachel Head, copyeditor of this book, who did a really great job making this book a perfect read even with my not-so-perfect English.

Finally, to Simon St. Laurent at O’Reilly Media, thanks for all your help and for trusting me when I presented this risky project in 2009, and for your help in continuing its evolution.

Creating a book about the mobile web was really a challenge; updating it after more than three years was hard, but it was worth it. Enjoy!

Get Programming the Mobile Web, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.