LEARNING JAVASCRIPT - Trang 299

CHAPTER 19

jQuery

jQuery is a popular library for manipulating the DOM and executing Ajax requests.

There’s nothing you can do with jQuery that you can’t do with the DOM API (jQuery

is, after all, built on the DOM API itself), but it offers three main advantages:

• jQuery protects you from idiosyncrasies in the way different browsers implement

the DOM API (especially older browsers).

• jQuery provides a simpler Ajax API (which is welcome because Ajax is used

heavily in today’s websites).

• jQuery provides many powerful and compact enhancements on the built-in

DOM API.

There is a growing community of web developers who feel that jQuery is no longer

necessary with the improvements in the DOM API and browser quality. This com‐

munity touts the performance and purity of “vanilla JavaScript.” It’s true that the first

point (browser idiosyncrasies) is becoming less true over time, but it has not vanished

altogether. I feel that jQuery remains relevant, and provides many features that would

be extremely time-consuming to reimplement in the DOM API. Whether or not you

choose to use jQuery, its ubiquity makes it hard to avoid entirely, and the wise web

developer will know the basics.

The Almighty Dollar (Sign)

jQuery was one of the first libraries to take advantage of JavaScript’s inclusion of the

dollar sign as an identifier. Perhaps it was hubris when the decision was first made,

but given jQuery’s ubiquity today, the decision seems prescient. When you include

275

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.