A few core W3C specifications are considered the cornerstones of today’s “enterprise” web apps: Web Storage, Web Workers, Geolocation, Device Orientation, and Web Sockets. In the chapters that follow, you’ll learn how to use these specifications in both mobile and desktop environments, as well as how to deal with fragmentation. Along the way, you’ll also discover the hidden details and intricacies that you must know to create the most amazing application the universe has ever seen.
Many books describe the drama of what went down between the W3C and the WHATWG during the making of HTML5, and just as many people will tell you that “HTML5” is now only a marketing term. I agree to some extent, but that’s only part of the story. The important things to understand, and the focus of this book, are the game-changing aspects and challenges of developing web applications with the specifications that have fallen under the HTML5 umbrella or just received attention with the rise of HTML5.
If you’re a developer aiming to write lightning-fast, HTML5-driven applications, as well as to understand how the server interacts with today’s newer client-side concepts and technologies, then this book is for you.
Also, if you are convinced that server-side generated markup is the way of the future, then chances are you won’t enjoy this book. The topics covered here are mostly directed toward developers who think “offline first” and write modern web applications that start out not worrying about the server. The main idea driving this book is to use the web browser as a platform.
The world of HTLM5 and mobile is moving at light speed, and we are witnessing a revolution and shift from traditional server-side concepts to heavier client-side ideas. In this environment, building a web app purely from HTML5 and related specifications is complicated and challenging, to say the least. These standards can adapt gracefully across mobile and desktop browsers, however, and this book will help you shoulder the challenge.
Chapter 1 and Chapter 2 start with an overview of the Mobile Web and will help you get a good grasp on which browsers support the standards that this book talks about and which browsers you should support. Here you’ll learn on how to grade browsers so that your development team, QA team, and customers will know where you stand on browser support.
Chapter 3 jumps straight into developing a mobile web application with HTML5. This chapter will give you a starting point for building an application with native-like touch events and transitions. You’ll also learn to add offline support with the AppCache and dynamically enhance your app based on the type of network the user is on (3G, WiFi, an so on).
The remaining chapters go into detail on the five main HTML5 specifications. You’ll learn about the raw implementation of each specification, as well as how it’s used in real-world scenarios and use cases. Each chapter ends with a look at the frameworks available that support each technology.
For example, Chapter 5 takes a broad look at WebSockets and how you can use it on the client and server. This is the only chapter that goes into detail on server-side code. You’ll set up a simple WebSocket server and compare frameworks that can be used across mobile and desktop browsers. The chapter also contains a detailed comparison of Socket.IO, Vert.x, and Atmosphere.
Chapter 6 goes into detail on Web Storage. You’ll see how today’s top sites like Google, Yahoo!, Twitter, and Amazon are storing data on the client side and investigate the best ways to store data along with a breakdown of available frameworks.
Next, Chapter 7 looks at Geolocation and discusses real-world uses of tracking users with mobile web browsers and other concepts. This chapter outlines how to use the technology and where you might encounter pitfalls in various implementations.
Chapter 8 covers the Device Orientation API. Although it’s not the most glorious specification in existence, it has extremely valuable and valid uses, as you’ll learn. This chapter ends with an implementation using orientation for page navigation on mobile devices.
Focused on Web Workers, Chapter 9 goes into practical uses of threading in the browser, delving into more detail than simply processing prime numbers in a separate thread. The chapter provides real-world examples of using Web Workers for processing image data and shows you how to create your own thread pool.
By the end of the book, you should be comfortable with writing your own HTML5 web app that works across any browsers you wish to support. You will have a true understanding of what you can build with HTML5, its available frameworks, and today’s web browsers.
The following typographical conventions are used in this book:
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
This icon signifies a tip, suggestion, or general note.
This icon indicates a warning or caution.
This book is here to help you get your job done. In general, you may use the code in this book 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.
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at email@example.com.
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.
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)|
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page here.
To comment or ask technical questions about this book, send email to firstname.lastname@example.org.
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
This book is dedicated to my incredible wife, Kristen, and our beautiful children, Adam and Stella. I also thank and dedicate this effort to Jesus Christ, who has given me the talent and ability to write this book.
The book would not have been possible without Meghan Blanchette and Simon St. Laurent continually pushing me to do better. I’m not a super easy guy to work with and can be quite lazy at times ☺, so they deserve serious props.
Also, many, many thanks to Douglas Campos, Brian Leroux, Divya Manian, Jason Porter, Shelley Powers, and Darren Nelsen for taking the time to review this book. I sought out the best developers, authors, and speakers in the industry to provide feedback, and they pushed me to places I did not think about. They gave me great perspective on the different aspects of HTML5 and today’s Web. It was an honor to work with them and have their input.
Last but not least, the open source community around HTML5 and open web technologies is my source of inspiration, ideas, and fuel for this book. I would not be where I am today without the countless people who give so much back to the community from which they take. So thanks to you all.