LEARNING JAVASCRIPT - Trang 281

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 Java‐

Script 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 sup‐

port 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 Java‐

Script engine that you don’t control. Worse, you may not even have reliable informa‐

tion about what browser is being used.
So-called “evergreen” browsers are cutting into this problem; by automatically updat‐

ing (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, you will have to ship ES5

for the foreseeable future. This isn’t the end of the world: transcompilation still pro‐

257

Liên Kết Chia Sẽ

** Đây là liên kết chia sẻ bới cộng đồng người dùng, chúng tôi không chịu trách nhiệm gì về nội dung của các thông tin này. Nếu có liên kết nào không phù hợp xin hãy báo cho admin.