Almost nobody reads past the first sentence or two of a preface, so I’ll say the most important thing right away: this book is about programming Chrome Apps, not Chrome Extensions or web apps in general.
Still here? There’s some more important stuff to know, so please continue.
Chapter 1 explains in detail what a Chrome App is, but briefly, its relationship to Chrome is the same as a Windows app to Windows, or a Mac app to OS X: an app that you install on the platform and that makes use of application program interfaces (APIs) unique to that platform. This would be obvious but for the fact that the platform in this case, Chrome, is better known as a web browser and most of the “apps” that you run on it are really just fancy web pages. I’m thinking of Gmail, Facebook, Amazon, and a zillion others. Hence the confusion.
Why consider programming a Chrome App at all? Here are two good reasons:
I’m unable to think of any other platform that offers these two advantages.
With the good comes the not-so-good. Here are the chief disadvantages of Chrome Apps:
A disclaimer: I’m not with Google, never have been, don’t even know anyone who works on Chrome at Google, and Google didn’t authorize this book. So, even though you won’t get any inside info in this book, you will get an entirely objective viewpoint. If I think something is screwed up, I’ll let you know.
In the world of web-programming books, this one’s fairly advanced, as I assume you already know JavaScript, HTML, CSS, and your way around the Document Object Model (DOM), which is a JavaScript object that represents the HTML elements of a web page. That said, my use of those technologies is fairly basic, so if you’re rusty or don’t mind jumping off a metaphorical cliff, you can read up on what I’m assuming you know as you encounter it.
Some popular technologies sometimes used to write Chrome Apps, such as jQuery and the AngularJS framework, aren’t covered in this book, because they aren’t specific to Chrome Apps and because they would obscure the example code. That code might be clearer to those who know these tools, but it would greatly inconvenience everyone else. Rather, I’ve tried to write the examples in the simplest possible way, using plain, unadulterated JavaScript. Another point is that cross-browser portability, an important benefit of these technologies ordinarily, is irrelevant when you’re writing a Chrome App.
I first wrote a Chrome App—then called a “Packaged App”—a few years ago when they were first released by Google. At that time, they were an offshoot of Chrome Extensions, and the documentation had the terminology for Apps and Extensions throughly confused. I got my app running, but it was obvious that apps for Chrome had a long way to go.
By late 2013, things had been cleaned up a lot. They were now called Chrome Apps, there were a lot more APIs, and the documentation was better, though still not well edited.
Meanwhile, Samsung had introduced a $250 Chromebook. I bought one and realized that for most of what I did when I wasn’t downstairs in my office, it was just as good as my MacBook Air. I wasn’t the only one to feel this way: today, Chromebooks are at or near the top of Amazon’s laptop best-seller list.
So, here’s the book I wish I’d had when I started with Chrome Apps. Now that it’s in your hands, you can start way ahead of where I was.
At this point most prefaces describe what’s in each chapter, but I’ve always thought that was silly because the same information is in the Table of Contents. I will say this much: read all of Chapter 1 carefully, even if you’re in the habit of skipping the first chapter of any programming book, because that’s where I explain how Chrome Apps are different from other things you run in a browser and, most important, their limitations relative to ordinary web pages. After that, I’ve written the rest to be read sequentially because later chapters build on earlier ones, but you can certainly skip around if you want.
There’s lots of code in this book, but I usually explain it in small bites so that you can more easily digest it. That might make it hard for you to see what’s going on in the app as a whole, so, as I go through an app, keep its code open in a text editor as a reference. See the section Using Code Examples a bit later in this Preface for information on how to get the code.
I’ll refer to URLs for documentation throughout this book, but the most important one is Google’s official Chrome App site at developer.chrome.com/apps. You’ll want to look around that site right away, and you’ll likely keep going back to it as you read this book.
The following typographical conventions are used in this book:
Constant width
This element signifies a general note.
You can download supplemental material (code examples, exercises, and so on) at https://github.com/oreillymedia/programming_chrome_apps.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it 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 Chrome Apps by Marc Rochkind (O’Reilly). Copyright 2015 Marc Rochkind, 978-1-491-90428-2.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com.
Safari Books Online 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.
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://bit.ly/programming_chrome_apps.
To comment or ask technical questions about this book, send email to bookquestions@oreilly.com.
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
I first met Tim O’Reilly in the late 1980s, after my book Advanced UNIX Programming had been out for a couple of years. He seemed to be publishing on all the hot Unix topics of the day. I went on to write three more books but never managed to do one with Tim’s company. After decades of wishing I had an animal of my own, it’s finally happened: I’m a crested screamer! Thanks, Tim, for all you’ve done for programmers over the years.
I’d also like to thank my editor, Brian MacDonald, for all of his astute comments; Heather Scherer, the project manager; and the technical reviewers, who helped greatly in improving the book. Thanks, too, go to Bob Russell, a terrific copyeditor, whose suggestions make the book seem like it was written by a better writer than me.