*****************************************************
*****************************************************
Your ebook has decrypted.
The TXT file just save 20% of ebook content.
Please register the software, then get all contents and the valid ebook format.
*****************************************************
*****************************************************
Title : JavaScript and HTML5 Now
Author: Simpson, Kyle
Description: <p>This insightful overview provides striking examples of how
JavaScript and HTML5 have teamed up to give the Web a truly open platform. Author
Kyle Simpson (<i>HTML5 Cookbook</i>) shows you how JavaScript unlocks the power of
all of the new functionality in HTML5, giving web applications the capabilities
developers have wanted for years. These technologies now provide the raw tools you
need in the presentation layer to replace everything you used to do with Flash.</p>
[image "JavaScript Starter Kit 2012 ad" file=image_rsrcDH.jpg] JavaScript and
HTML5 NowKyle Simpson [image file=image_rsrcDJ.jpg] Beijing • Cambridge • Farnham •
Köln • Sebastopol • Tokyo
Special Upgrade OfferIf you purchased this ebook directly from [Link], you
have the following benefits:
DRM-free ebooks — use your ebooks across devices without restrictions or
limitations
Multiple formats — use on your laptop, tablet, or phone
Lifetime access, with free updates
Dropbox syncing — your files, anywhere
If you purchased this ebook from another retailer, you can upgrade your ebook to
take advantage of all these benefits for just $4.99. Click here to access your
ebook upgrade.
Please note that upgrade offers are not available from sample content.
Chapter 1. JavaScript and HTML5 NowHTML and JavaScript are staples of web
technology; they’ve been the foundation of “the modern web” for well over a decade.
HTML is how the browser shows us content, and JavaScript is how we go beyond simply
reading to meaningful interaction with that content. Developers and users demand
more and more of these intertwined technologies every day.
You can see the obvious power these technologies are bringing to countless
Internet-connected devices worldwide on your smartphone, or in an email client
running in your browser. From social games to productivity apps to geo-aware check-
ins to billion-dollar photo sharing services, the immersive interactivity of the
Web is transforming how we perceive and relate, not only with computers, but
ultimately with each other.
HTML5 and JavaScript push this further, adding new features that let you build more
powerful applications with new kinds of interactivity.
More than AjaxA few years ago, the rise of Ajax gave developers a whole new
approach to building applications on the Web. Taking advantage of the ability of
JavaScript to modify the current page in the browser in response to information
from a web server, without requiring the user to initiate a separate page load,
Ajax unleashed unprecedented creativity and imagination, stretching the boundaries
of the Web to its edges and beyond. It’s almost as if Ajax enlightened us that
literally anything was possible on the Web, and so we demanded everything, and
more.
When Ajax arose, the browser landscape was dominated by only a few players.
Netscape and Internet Explorer (IE) were the viewports through which we experienced
the Web. IE’s dominance in the browser market gave Microsoft the drastic luxury of
settling into their lead and virtually halting new discovery and experimentation.
What were the burgeoning web designers and developers to do when what they imagined
for the Web exceeded the cold reality of what was possible? The Web “made a way”,
and that way was Flash. Flash, originally built in the mid-’90s, and eventually
shepherded by Macromedia and then Adobe, had been growing slowly in popularity for
several years. It was a technology that promised things in a browser that
JavaScript and HTML alone simply could not do. The nail in search of a hammer had
found its match.
Flash freed itself of the limitations of HTML and JavaScript by using a plug-in, a
special extension that must be installed in every single browser, to interpret
Flash content, display it, and receive interaction from the user. It is, for all
practical purposes, a “black box” dropped into an existing page, where what goes on
inside the Flash content is often quite unlike (and unrelated to) what’s going on
around it in the page. Because the Flash plug-in was ubiquitous enough to serve the
majority of web users, truly interactive web content didn’t need to be tied to the
limitations of JavaScript and HTML, nor did we have to wait for the few browser
gatekeepers to give us what we wanted.
If Microsoft was saying that the Web had come as far as it ever needed to go, Flash
challenged that assertion and continued to experiment and evolve. And the creators
of ever-more complex web content simply changed their medium, but kept on fueling
their imaginations. Flash became the go-to technology for any content/interactivity
of any significant complexity. It cemented itself as the platform of choice for
animations, games, and visual effects.
JavaScript was a second-class citizen in this world; the fallback we used only when
we had to. Whatever JavaScript could do, Flash could do it, and much more. But not
everyone jumped ship. JavaScript developers created popular frameworks the Web
knows today, like Prototype, jQuery, and Dojo. Mainly, though, these frameworks
spent much of their early efforts just trying to smooth out and fix many
shortcomings of JavaScript itself.
Microsoft did little over this period to improve JavaScript, but this left the door
open for other browser vendors to join the mix. Mozilla Firefox rose from Netscape.
Opera had a browser, and so did Apple in Safari. Eventually, even Google entered
the field with their Chrome browser. More browsers meant new innovation in web
technology, especially JavaScript.
The rediscovery of JavaScript also started the “cross-browser wars”, an epic (and
ongoing!) battle on the part of developers to write code that could somehow run
predictably in an unpredictable browser world. These new options gave hope that
JavaScript, the language that already ships natively in all browsers, could perhaps
come back to life, and finally grow and improve despite its warts. This would take
work, though; perhaps no other language has received so much negative attention for
its warts.
However, JavaScript the language had strengths as well. JavaScript was in need of a
marketing campaign, so to speak. Douglas Crockford’s “JavaScript: The Good Parts,”
for all the controversy over the details, was in ways the marketing brochure that
JavaScript needed to (re)capture developers’ attention. Now we actually knew how to
use just “the good parts” and avoid the pitfalls of the rest.
By 2010, Flash and JavaScript coexisted as two powerful choices in the web
technology platform. Flash was not even the only plug-in approach; Microsoft had
their own answer in Silverlight. Increasingly, the question for developers became:
“Do I rely on a plug-in or not?” And for many, the answer was, “both.”