O'Reilly logo

Learning JavaScript, 3rd Edition by Ethan Brown

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 18. JavaScript in the Browser

JavaScript began its life as a browser scripting language, and now holds a near-complete monopoly in that role. This chapter is for anyone who’s working with JavaScript in the browser. The language may be the same, but there are some special considerations and APIs for this scenario.

Fully covering browser-based JavaScript development is a whole book in itself. The goal of this chapter is to introduce you to the important core concepts in browser development, which will give you a solid foundation. At the end of this chapter, I will recommend some additional learning resources.

ES5 or ES6?

Hopefully by now you are convinced of the utility of the enhancements ES6 brings. Unfortunately, it will be a while before you can rely on strong and consistent ES6 support on the Web.

On the server side, you can know with certainty which ES6 features are supported (assuming you have control of the JavaScript engine). On the Web, you send your precious code out into the ether, over HTTP(S), where it’s executed by some JavaScript engine that you don’t control. Worse, you may not even have reliable information about what browser is being used.

So-called “evergreen” browsers are cutting into this problem; by automatically updating (without asking the user), they are allowing new web standards to be rolled out more quickly and consistently. However, this only reduces the problem instead of eliminating it.

Unless you can somehow control your user’s environment, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required