<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>https://web.dev/</id>
  <title>Michael Mahemoff on web.dev</title>
  <updated>2026-04-15T23:21:06Z</updated>
  <author>
    <name>Michael Mahemoff</name>
  </author>
  <link href="https://web.dev/authors/mahemoff/feed.xml" rel="self"/>
  <link href="https://web.dev/"/>
  <icon>https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/8qXOF2DbhYTGnJG5qHXh.png?auto=format</icon>
  <logo>https://web.dev/images/shared/rss-banner.png</logo>
  <subtitle>Freelance Web Developer</subtitle>
  
  
  <entry>
    <title>HTML5 vs Native</title>
    <link href="https://web.dev/nativedebate/"/>
    <updated>2011-06-03T00:00:00Z</updated>
    <id>https://web.dev/nativedebate/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;introduction&quot;&gt;Introduction &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#introduction&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Mobile apps and HTML5 are two of the hottest technologies right now, and
there&#39;s plenty of overlap. Web apps run in mobile browsers and can also be
re-packaged as native apps on the various mobile platforms. With the wide
range of platforms to support, combined with the sheer power of mobile
browsers, developers are turning to HTML5 as a &amp;quot;write one, run many&amp;quot;
solution. But is it really viable? There are still compelling reasons to go
native, and clearly, many developers are indeed going that route. This
article is a debate on native versus the web.&lt;/p&gt;
&lt;h2 id=&quot;feature-richness&quot;&gt;Feature Richness &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#feature-richness&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;point-native-can-do-more&quot;&gt;Point: Native can do more &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#point-native-can-do-more&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We can divide mobile functionality into two dimensions: the
experience of the app itself, and the way it hooks into the device&#39;s
ecosystem, e.g. for Android, this would be features like widgets and
notifications. Native excels in both dimensions.&lt;/p&gt;
&lt;p&gt;In terms of app experience, native apps can do more. They can easily get
hold of swipe events, mutlitouch even, for those platforms which support it.
They can typically act on hard keys being pressed, like Android&#39;s search button
and volume controls.  They can access hardware too, like GPS and camera. And
with the user&#39;s permission, some platforms provide unfettered access to the
operating system. Just try detecting how much battery remains with HTML5!&lt;/p&gt;
&lt;p&gt;It&#39;s more than the in-app experience though. An operating system
like Android provides different ways for apps to interact with
users, and indeed, with other apps. You have active widgets on the
homepage. You have notifications, which show up in the device&#39;s
status bar. And you have intents, which allow your app to announce
itself as providing a general service which other apps might require
on occasion.&lt;/p&gt;
&lt;h3 id=&quot;counterpoint-native-features-can-be-augmented,-and-the-web-is-catching-up-anyway&quot;&gt;Counterpoint: Native features can be augmented, and the web is catching up anyway &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#counterpoint-native-features-can-be-augmented,-and-the-web-is-catching-up-anyway&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It&#39;s true that many in-app features are simply beyond
reach for an HTML5 app. No matter how hot your web-fu skills are,
if your app is stuck in a sandbox with no camera API, it won&#39;t be
taking snaps anytime soon! Fortunately, you don&#39;t have to be in
that sandbox. If you really need your web app to take a photo, you
can create a native app, one with an embedded web view which provides
the bulk of the user interface. This is how the open-source
PhoneGap framework operates: it fills the gap by exposing native
features as web services, which the web view calls using a
standard networking API. When you build a hybrid app like this,
you&#39;re also able to hook into those platform features like
widgets, notifications, and intents.&lt;/p&gt;
&lt;p&gt;Making a hybrid - native plus web - app is hardly an ideal
solution. It adds complexity and applies only to web apps wrapped as
native apps, rather than traditional websites accessed from a mobile
browser. But it mightn&#39;t be necessary for long. Web standards are
evolving rapidly, and modern mobile browsers are keeping pace.
Offline storage, geolocation, canvas graphics, and video/audio
playback all  enjoy widespread support among modern smarpthones, for example.
Even camera is starting to be supported  -  as of Android 3.1, it&#39;s
possible to capture photos and videos using web standards.  And the latest iOS
browser supports WebSocket for 2-way streaming, as well as device orientation
detection.&lt;/p&gt;
&lt;p&gt;Overall, mobile is evolving. But the web is also evolving, and fast. Among
desktop browsers alone, there are five major browser vendors evolving standards
and adding features at lightning pace.  While it&#39;s not a trivial process to
port these features to mobile, many of them have already made their way into
the mobile browsers.&lt;/p&gt;
&lt;p&gt;Native is a fast-moving target, but the web is closing the gap.&lt;/p&gt;
&lt;h2 id=&quot;performance&quot;&gt;Performance &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#performance&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;point-native-runs-faster&quot;&gt;Point: Native runs faster &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#point-native-runs-faster&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Native apps don&#39;t have the web runtime barrier to deal with. They
run close to the metal and can take advantage of performance
boosters like GPU acceleration and multithreading.&lt;/p&gt;
&lt;h3 id=&quot;counterpoint-web-runtimes-are-much-faster-today,-and-most-apps-dont-need-the-speed-anyway&quot;&gt;Counterpoint: Web runtimes are much faster today, and most apps don&#39;t need the speed anyway &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#counterpoint-web-runtimes-are-much-faster-today,-and-most-apps-dont-need-the-speed-anyway&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It would be an understatement to say the web has gotten faster in
recent years. V8, the JavaScript engine that ships with Chrome, was a
major development in web performance when it launched, and since then, it
has only gotten faster:&lt;/p&gt;
&lt;figure&gt;
&lt;a href=&quot;http://blog.chromium.org/2010/12/new-crankshaft-for-v8.html&quot;&gt;
&lt;img alt=&quot;V8 performance graph&quot; decoding=&quot;async&quot; height=&quot;230&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 400px) 400px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=800 800w&quot; width=&quot;400&quot; /&gt;
&lt;/a&gt;
&lt;/figure&gt;
&lt;p&gt;Graphic rendering engines has also sped up the web, and now hardware
acceleration is starting to happen. Have a look at the speed bump provided by
hardware accelerated-canvas:&lt;/p&gt;
&lt;a href=&quot;http://www.maximumpc.com/article/news/hardware-accelerated_chrome_7_60x_faster_previous_versions&quot;&gt;
&lt;img alt=&quot;Hardware accelerated-canvas graph&quot; decoding=&quot;async&quot; height=&quot;230&quot; loading=&quot;lazy&quot; sizes=&quot;(min-width: 400px) 400px, calc(100vw - 48px)&quot; src=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&quot; srcset=&quot;https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=200 200w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=228 228w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=260 260w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=296 296w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=338 338w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=385 385w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=439 439w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=500 500w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=571 571w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=650 650w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=741 741w, https://web-dev.imgix.net/image/T4FyVKpzu4WKF1kBNvXepbi08t52/tUAj9JVwmvVqvmxfypAV.png?auto=format&amp;w=800 800w&quot; width=&quot;400&quot; /&gt;
&lt;/a&gt;
&lt;p&gt;In addition, the new Web Workers API makes multithreading a possibility, and
modern web developers can also call on a range of performance-optimized libraries,
and well-researched performance optimizion techniques. While most of those started
life on the desktop web, they are still relevant to mobile, and there&#39;s
increased attention paid to mobile, e.g.  performance guru Steve Souders has &lt;a href=&quot;http://stevesouders.com/mobileperf/&quot; rel=&quot;noopener&quot;&gt;page dedicated to mobile performance tools&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Not all desktop advances have made their way to every mobile platform yet,
but the trends indicate they are on their way. It&#39;s also important to note that
the majority of mobile apps aren&#39;t bleeding-edge 3D games, but fundamentally
information-based: news, mail, timetables, social networks, etc. Visit a few
sites from your mobile, e.g. GMail, Amazon, Twitter, and you can confirm mobile
web performance is more than adequate. As for games, basic ones are already
feasible with 2D canvas, and WebGL is starting to appear on mobiles - see
Firefox 4. Until it&#39;s widespread, there is a growing family of frameworks which
compile WebGL apps to native apps that can take advantage of OpenGL, e.g. &lt;a href=&quot;http://impactjs.com/&quot; rel=&quot;noopener&quot;&gt;ImpactJS&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;developer-experience&quot;&gt;Developer Experience &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#developer-experience&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;point-native-is-easier-to-develop&quot;&gt;Point: Native is easier to develop &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#point-native-is-easier-to-develop&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Native apps use robust programming languages (e.g. Java,
Objective C, C++) which were designed for complex application
development and have a proven track record. The APIs were designed
ground-up to support the platform at hand. You can easily debug apps
in desktop emulators which provide a close representation of the
target device.&lt;/p&gt;
&lt;p&gt;What makes web development particularly troublesome is the huge
diversity of browsers and runtimes. When your app runs, it&#39;s no
guarantee feature X will be available. And even if it is, how will
the browser implement it? Standards are open to interpretation.&lt;/p&gt;
&lt;h3 id=&quot;counterpoint-web-is-often-easier-to-develop,-especially-if-targeting-multiple-devices&quot;&gt;Counterpoint: Web is often easier to develop, especially if targeting multiple devices &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#counterpoint-web-is-often-easier-to-develop,-especially-if-targeting-multiple-devices&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Let&#39;s tackle core technology first. It&#39;s true that web standards
were originally conceived in an era when the web was fundamentally
about documents, not apps, with JavaScript built and deployed in
just 10 days! But they&#39;ve turned out to be much more capable than
imagined - web developers have learned to leverage the good parts
and tame the bad parts, with patterns now understood for scaleable
design. Furthermore, the standards are not standing still, and
efforts like HTML5, CSS3, and EcmaScript Harmony are all improving
the developer experience. Whether you prefer C++ or Java or
JavaScript is a matter of religious debate, and also depends on your
legacy code base. But we can certainly include JavaScript as a
serious contender these days.&lt;/p&gt;
&lt;p&gt;The flipside to browser/runtime fragmentation is the fact that
all these environments exist in the first place. Develop an Android
app in Java, and you&#39;re faced with a full port to Objective C to
support iOS. Develop a web app once and it will run in Android and
iOS, not to mention WebOS, BlackBerry, Windows Mobile and… well,
that&#39;s the theory anyway. In practice, you&#39;ll need to tweak things
for each platform if you really want to get the experience right.
But you&#39;d have to do that in native too, for most mobile operating
systems - there are different versions and different devices.&lt;/p&gt;
&lt;p&gt;The good news is &amp;quot;fragmentation&amp;quot; has always been this way on the
web, and there are well-known techniques to deal with it. Most
importantly, the principle of progressive enhancement urges
developers to target a basic device first, and add layers of
platform-specific awesomeness where it&#39;s available. The mantra of
feature detection also helps and these days, we have library support
from the likes of &lt;a href=&quot;http://www.modernizr.com/&quot; rel=&quot;noopener&quot;&gt;Modernizr&lt;/a&gt; to support responsive
web design. With judicious use of these techniques, you can
expand your reach to the vast majority of devices, even
old-school &amp;quot;feature phones&amp;quot;, even form factors like watches and
TVs, regardless of make and OS. Witness our &lt;a href=&quot;http://www.google.com/events/io/2011/sessions/mobile-web-development-from-zero-to-hero.html&quot; rel=&quot;noopener&quot;&gt;multi-UI demonstration&lt;/a&gt; at Google IO 2011,
where we targeted distinct form factors (feature phone, smartphone, tablet, desktop, TV) with
a common code base of logic and markup.&lt;/p&gt;
&lt;h2 id=&quot;look-and-feel&quot;&gt;Look-And-Feel &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#look-and-feel&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;point-native-fits-platform-look-and-feel&quot;&gt;Point: Native fits platform look-and-feel &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#point-native-fits-platform-look-and-feel&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;One of the defining features of any platform is its look and
feel. Users come to expect controls to be presented consistently and
manipiulated in the same way. There are certain idioms which vary
from platform to platform, e.g. what happens when the user performs
a &amp;quot;long hold&amp;quot; (keep touching an element for several seconds)?
Plaforms have standard idioms for such things, and you can&#39;t satisfy them all with a single HTML5 app.&lt;/p&gt;
&lt;p&gt;Furthermore, platform look-and-feel is orchestrated by the platform&#39;s native
software library, whose widgets encapsulate the kind of look and feel users
expect. You get a lot of the expected look-and-feel &amp;quot;for free&amp;quot; just by using
the native toolkit.&lt;/p&gt;
&lt;h3 id=&quot;counterpoint-the-web-has-its-own-look-and-feel,-and-you-can-also-customize-web-interface-for-those-platforms-you-care-about-the-most&quot;&gt;Counterpoint: The web has its own look-and-feel, and you can also customize web interface for those platforms you care about the most &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#counterpoint-the-web-has-its-own-look-and-feel,-and-you-can-also-customize-web-interface-for-those-platforms-you-care-about-the-most&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As explained in the previous section, the way of web development
is to write a basic &amp;quot;one size fits all&amp;quot; version, and then
progressively enhance it. While the enhancement is typically based
on features, you can also enhance it by targeting those platforms
you care the most about. This is a kind of &amp;quot;browser detection&amp;quot;,
which is sometimes frowned upon by the web community, mostly because
there are so many possible browsers out there. But if you do view
two or three platforms with a very high priority, and you&#39;re willing
to make the extra effort in order to stack up against native
alternatives, this may be the way to go.&lt;/p&gt;
&lt;p&gt;As far as the baseline version, the web has its own
look-and-feel, and we can even say each mobile platform has its own
&amp;quot;web look-and-feel&amp;quot; established by the default browser and web
runtime. &amp;quot;Web look-and-feel&amp;quot; may be fine for your users, and in
fact, allows you to achieve a greater degree of consistency with the
desktop browsing experience, as well as those on other devices the
user might be working with. Furthermore, there are many successful
apps which don&#39;t much support native look and feel anyway. This is
certainly true of games (does your favorite mobile game follow your mobile
OS&#39;s look and feel?), and even true of more conventional apps, e.g. check out
the more popular native Twitter clients on your platform of choice, and you&#39;ll
see a wide range of user-interface mechanisms at work.&lt;/p&gt;
&lt;h2 id=&quot;discoverability&quot;&gt;Discoverability &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#discoverability&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;point-native-apps-are-easier-to-discover&quot;&gt;Point: Native apps are easier to discover &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#point-native-apps-are-easier-to-discover&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;App distribution mechanisms, like Android&#39;s Market and Apple&#39;s
App Store, have been overwhelmingly popular in recent years and are
a major driving force for the entire mobile industry. Any developer
can submit their native app to the marketplace, where users can
discover it through a combination of browsing, searching, and
getting recommendations. Not only that, but if you&#39;ve done your job
right, the glowing ratings and comments will convince users to hit
the all-important install button.&lt;/p&gt;
&lt;h3 id=&quot;counterpoint-actually,-web-apps-are-easier-to-discover&quot;&gt;Counterpoint: Actually, web apps are easier to discover &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#counterpoint-actually,-web-apps-are-easier-to-discover&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The web is arguably the most discoverable medium ever created. In
the humble URL, we have (in theory, at least) a unique identifier
for everything ever published on the web, which includes any apps
published on standard websites. Search engines make it easy to
discover that content and other websites can link to it, including
catalogues of web apps similar to mobile marketplaces. Indeed, any
individual can share web apps with their friends by just linking to
it in emails and social network messages. Links can be sent in SMS
too, where mobile users will be able to click on the link and launch
the app in their device&#39;s browser.&lt;/p&gt;
&lt;p&gt;We don&#39;t yet have the same marketplaces where users can rate and
comment on apps, but that&#39;s changing too. Read on…&lt;/p&gt;
&lt;h2 id=&quot;monetization&quot;&gt;Monetization &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#monetization&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;point-native-can-be-monetized&quot;&gt;Point: Native can be monetized &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#point-native-can-be-monetized&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&amp;quot;6 year-old makes app during lunch hour, sells a zillion copies
at $3 each&amp;quot;. You see that headline a lot these days, so it&#39;s no
wonder developers big and small are looking to the mobile
marketplaces for monetization. Mobile platforms offer several
avenues for developers to directly charge for their apps. Simplest
is the one-time payment, to unlock the app for all eternity. There
are also in-app payment and subscription mechanisms on offer in some
platforms, and they are tightly integrated in a consistent, secure,
mechanism. These newer forms of payment allow developers to convert
a smash-hit app into a long-term revenue stream.&lt;/p&gt;
&lt;p&gt;In addition to app payments, you can monetize with traditional
web models, such as advertising and sponsorship.&lt;/p&gt;
&lt;h3 id=&quot;counterpoint-its-always-been-possible-to-monetize-on-the-web,-and-the-opportunities-are-growing&quot;&gt;Counterpoint: It&#39;s always been possible to monetize on the web, and the opportunities are growing &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#counterpoint-its-always-been-possible-to-monetize-on-the-web,-and-the-opportunities-are-growing&quot;&gt;#&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The web would not be the engine of modern industry if there
weren&#39;t ample opportunities to cash in. Although direct
&amp;quot;pay-per-use&amp;quot; mechanisms haven&#39;t yet flourished, there are various
niches where subscription-based &amp;quot;software as a service&amp;quot; solutions
have indeed become viable. Examples include Google Apps, 37Signals&#39;
range of products, and premium versions of various email services.
Furthermore, direct payments aren&#39;t the only way to profit from web
apps. There&#39;s online advertising, affiliate links, sponsorships,
cross-promotion to other products and services.&lt;/p&gt;
&lt;p&gt;Having said that, it&#39;s perfectly reasonable for a web developer
to read the headlines and experience a dash of payment envy. You
can&#39;t submit a web URL to the native marketplaces, so what&#39;s a web
developer to do? What you do is create a native &amp;quot;wrapper app&amp;quot; - for
each platform you want to target, create an empty native app that
simply contains a web view. The web view is where you embed the real
app. Then you just submit these apps to the various marketplaces
(and hopefully watch the money roll in!). There are probably
hundreds, if not thousands, of web-powered apps in the main
marketplaces today, some of them so cunningly assimilated that we
don&#39;t even know their web apps at all.&lt;/p&gt;
&lt;p&gt;The downside is the onus of cross-compiling to each
platform. Here&#39;s where an existing framework like PhoneGap can help.
Even better, there are web services like PhoneGap Build and
Apparatio under development. Point these websites to your code
repository, and out pops an Android app, an iOS app, and so
on… ready for you to submit to the respective stores. No installing
native SDKs on your machine; all you needed to build all these
native apps was a a code editor and a web browser.&lt;/p&gt;
&lt;p&gt;Will the marketplaces ever support web apps directly, without all
the overhead of wrapping them natively? It&#39;s not yet clear. We do
know that Google introduced the Chrome Web Store last year, and
although it applies only to the desktop, the store has triggered
interest from other browser vendors, and is overall part of a trend
towards web app catalogues, including some mobile-specific attempts.
It&#39;s early days for the concept of a web store, but the signs are
promising.&lt;/p&gt;
&lt;h2 id=&quot;conclusions&quot;&gt;Conclusions &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/nativedebate/#conclusions&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It would be nice to declare a winner here, but right now, there
is no clear winner. Some apps are best suited for native and some
are best suited for the web. The web stack arguably has more
momentum, but in terms of capabilities and execution qualities,
native apps are moving fast too. And unless there comes a time when
web technologies are a first-class citizen on the majority of mobile
OSs, native will always be an important consideration.&lt;/p&gt;
&lt;p&gt;One technique mentioned in this article is hybrid apps, and this
may be the best compromise for some developers: web view where it&#39;s
possible and platform-specific native components where it&#39;s not.&lt;/p&gt;
&lt;p&gt;If you do choose the web path, be mindful of web standards and
the principle of progressive enhancement. The web is a technology
that knows how to target the multitudes of devices and operating
systems around. Whether you choose to call it &amp;quot;fragmentation&amp;quot; or
&amp;quot;diversity&amp;quot;, the web embraces it and you developers can benefit from
all the prior art out there.&lt;/p&gt;
</content>
    <author>
      <name>Michael Mahemoff</name>
    </author>
  </entry>
  
  <entry>
    <title>A Simple Trip Meter using the Geolocation API</title>
    <link href="https://web.dev/trip-meter/"/>
    <updated>2010-05-24T00:00:00Z</updated>
    <id>https://web.dev/trip-meter/</id>
    <content type="html" mode="escaped">&lt;h2 id=&quot;introduction&quot;&gt;Introduction &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#introduction&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;http://dev.w3.org/geo/api/&quot; rel=&quot;noopener&quot;&gt;Geolocation API&lt;/a&gt; lets you find out where the user is and keep tabs on them as they move around, always with the user&#39;s consent. This functionality could be used as part of user queries, e.g. to guide someone to a destination point. It could also be used for &amp;quot;geo-tagging&amp;quot; some content the user has created, e.g. to mark where a photo was taken. The API is device-agnostic; it doesn&#39;t care how the browser determines location, so long as clients can request and receive location data in a standard way. The underlying mechanism might be via GPS, wifi, or simply asking the user to enter their location manually. Since any of these lookups is going to take some time, the API is asynchronous; you pass it a callback method whenever you request a location.&lt;/p&gt;
&lt;p&gt;The example here is a trip meter showing the initial location and maintaining a display of the distance they have travelled since the page was loaded.&lt;/p&gt;
&lt;h2 id=&quot;step-1-check-for-compatibility&quot;&gt;Step 1. Check for Compatibility &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#step-1-check-for-compatibility&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;wdi-browser-compat&quot;&gt;
  &lt;span class=&quot;wdi-browser-compat__label&quot;&gt;Browser support&lt;/span&gt;
  &lt;ul class=&quot;wdi-browser-compat__items&quot;&gt;
    &lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;chrome&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Chrome 5, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      5
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;firefox&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Firefox 3.5, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      3.5
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;edge&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Edge 12, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      12
    &lt;/span&gt;
    &lt;/li&gt;&lt;li class=&quot;wdi-browser-compat__item&quot;&gt;
    &lt;span class=&quot;wdi-browser-compat__icon&quot; data-browser=&quot;safari&quot;&gt;
      &lt;span class=&quot;visually-hidden&quot;&gt;Safari 5, Supported&lt;/span&gt;
    &lt;/span&gt;
    &lt;span class=&quot;wdi-browser-compat__version&quot; data-compat=&quot;yes&quot; title=&quot;Supported&quot; aria-label=&quot;Supported&quot;&gt;
      5
    &lt;/span&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
  &lt;a class=&quot;wdi-browser-compat__link&quot; href=&quot;https://developer.mozilla.org/docs/Web/API/Geolocation#browser_compatibility&quot; target=&quot;_blank&quot;&gt;Source&lt;/a&gt;
&lt;/div&gt;
&lt;p&gt;You can easily check for compatibility by testing for the presence of the geolocation object:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// check for Geolocation support&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;geolocation&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Geolocation is supported!&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;  console&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Geolocation is not supported for this Browser/OS version yet.&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;step-2-declare-the-trip-meter-html&quot;&gt;Step 2. Declare the Trip Meter HTML &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#step-2-declare-the-trip-meter-html&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this example, you&#39;re building a trip meter, so declare the following HTML:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;tripmeter&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Starting Location (lat, lon):&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;startLat&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;???&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;°, &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;startLon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;???&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;°&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Current Location (lat, lon):&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;currentLat&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;???&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;°, &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;currentLon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;???&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;°&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;Distance from starting location:&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;br&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;distance&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;0&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt; km&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The next few steps will use the Geolocation API to populate all those empty spans.&lt;/p&gt;
&lt;h2 id=&quot;step-3-determine-the-users-current-location&quot;&gt;Step 3. Determine the User&#39;s Current Location &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#step-3-determine-the-users-current-location&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;getCurrentPosition()&lt;/code&gt; will asynchronously report on the user&#39;s current location. Call it as soon as the page loads, so that it will correctly populate - and save for later - the starting position:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;onload&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; startPos&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;geolocation&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getCurrentPosition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;startPos &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; position&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;startLat&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; startPos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;latitude&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;startLon&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; startPos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;longitude&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;If this is the first time an application on this domain has requested permissions, the browser will
typically check for user consent. Depending on the browser, there may also be preferences to always
allow - or disallow - permission lookups, in which case the confirmation process will be bypassed.&lt;/p&gt;
&lt;p&gt;Having run this code, you should now be able to see the starting position. Depending on the location
device your browser is using, the position object might actually contain a lot more than just latitude
and longitude, e.g. it could include an altitude or a direction. You can explore further by logging
the position variable to the console.&lt;/p&gt;
&lt;h2 id=&quot;step-4-handle-errors&quot;&gt;Step 4. Handle Errors &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#step-4-handle-errors&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Unfortunately, not all location lookups are successful. Perhaps a GPS could not be located or
the user has suddenly disabled location lookups. A second, optional, argument to &lt;code&gt;getCurrentPosition()&lt;/code&gt;
will be called in the event of an error, so you can notify the user inside the callback:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;window&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;onload&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; startPos&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;geolocation&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getCurrentPosition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// same as above&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token function&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;Error occurred. Error code: &#39;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt; error&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;code&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// error.code can be:&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;//   0: unknown error&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;//   1: permission denied&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;//   2: position unavailable (error response from locaton provider)&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;//   3: timed out&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;step-5-monitor-the-users-location&quot;&gt;Step 5. Monitor the User&#39;s Location &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#step-5-monitor-the-users-location&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The previous call to &lt;code&gt;getCurrentPosition()&lt;/code&gt; was only executed once, on page load. To track changes,
use &lt;code&gt;watchPosition()&lt;/code&gt;. It will automatically notify a callback function whenever the user moves:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;geolocation&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;watchPosition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;currentLat&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; position&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;latitude&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;currentLon&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; position&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;longitude&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;h2 id=&quot;step-6-show-distance-travelled&quot;&gt;Step 6. Show Distance Travelled &lt;a class=&quot;headline-link&quot; href=&quot;https://web.dev/trip-meter/#step-6-show-distance-travelled&quot;&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This step isn&#39;t directly related to the Geolocation API, but rounds off the demo and provides an
example of how you might use location data. Add an extra line to the &lt;code&gt;watchPosition()&lt;/code&gt; handler to populate the distance travelled:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;navigator&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;geolocation&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;watchPosition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token comment&quot;&gt;// same as above&lt;/span&gt;&lt;br /&gt;document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;distance&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;innerHTML &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token function&quot;&gt;calculateDistance&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;startPos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;latitude&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; startPos&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;longitude&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;&lt;br /&gt;                    position&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;latitude&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; position&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;coords&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;longitude&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;p&gt;The &lt;code&gt;calculateDistance()&lt;/code&gt; function performs a geometric algorithm to determine
the distance between two co-ordinates. The Javascript implementation is adapted from &lt;a href=&quot;http://www.movable-type.co.uk/scripts/latlong.html&quot; rel=&quot;noopener&quot;&gt;a script provided by Moveable Type&lt;/a&gt;
under a &lt;a href=&quot;http://creativecommons.org/licenses/by/3.0/&quot; rel=&quot;noopener&quot;&gt;Creative Commons license&lt;/a&gt;:&lt;/p&gt;
&lt;div&gt;&lt;pre class=&quot;language-js&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;calculateDistance&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;lat1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; lon1&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; lat2&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; lon2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;R&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;6371&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// km&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; dLat &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;lat2 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; lat1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toRad&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; dLon &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;lon2 &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; lon1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toRad&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; a &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dLat &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dLat &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;+&lt;/span&gt;&lt;br /&gt;        Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;lat1&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toRad&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;cos&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;lat2&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;toRad&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;br /&gt;        Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dLon &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;dLon &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; c &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;atan2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;a&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt; a&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;var&lt;/span&gt; d &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;R&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; c&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; d&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token class-name&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;prototype&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function-variable function&quot;&gt;toRad&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt; Math&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;PI&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;180&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content>
    <author>
      <name>Michael Mahemoff</name>
    </author>
  </entry>
</feed>
