Chapter 1. Your First Chrome App
In this chapter, I’ll take you step by step through building your first, simple Chrome App. I’ll explain the key differences between a Chrome App and an ordinary web app of the sort with which you may already be familiar. I’ll tell you how to run your app, how to use the new Chrome Dev Editor, and how to publish it to the Chrome Web Store.
From Web Apps to Chrome Apps
To build this first Chrome App, let’s begin with something you already know how to build: a simple web app that converts meters to feet, as shown in Figure 1-1. To use the app, you enter an amount of meters in the first field and then click the Convert button. The app then displays the equivalent amount in feet in the second field.

Like all web apps, the user interface for our sample app is built from an HTML file, (index.html), which you can see in the following:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Converter</title>
<script src="converter.js"></script>
</head>
<body>
<p>
<label for="meters">Meters:</label>
<input type="text" id="meters">
</p><p>
<label for="feet">Feet:</label>
<input type="text" id="feet" readonly>
</p><p>
<button id="convert">Convert</button>
</p>
</body>
</html>The <script> tag brings in the following JavaScript, which is in the file converter.js:
window.onload = function () { document.querySelector("#convert").addEventListener("click", ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access