Beyond jQuery (The Book + 1 free "code hand" laptop sticker)
Beyond jQuery
Free yourself from the chains of jQuery by discovering the power of JavaScript and the modern web API
About the Book
Recently published by Apress. Order a copy on Amazon.
jQuery seems to be mindlessly injected into the vast majority of web applications and libraries. In some cases, there there may be no logical reason for pulling in jQuery as a dependency. For example: a library that only needs to perform a few simple element selections or DOM manipulations. Many web developers don’t really know when they need to use jQuery, and when they don’t. Pulling in this dependency seems to be a standard step when setting up a new library or web application. You shouldn’t be a jQuery developer, you should be a web developer, and part of being an effective web developer is a firm grasp on the underpinnings of web development.
Surprisingly, while browsers and JavaScript have improved significantly, the use of jQuery on the web has actually grown. It is surprisingly common to learn jQuery first, and JavaScript along with the web API much later on (and sometimes not at all). Relying solely on jQuery as your window to the web leaves large gaps in your knowledge. This in turn results in frustration when the abstraction that jQuery provides “leaks” and exposes you to the native aspects of the browser. In some cases, jQuery is ill-equipped to solve problems (such as file uploading). In these instances, those insistent on working exclusively through a library struggle as they do not have the knowledge or confidence to deal directly with the native browser API.
In addition to being unnecessary in many instances, jQuery may adversely affect the performance of your project (sometimes significantly). Even something as simple as $(element).hide() has unexpected and serious performance implications. “Beyond jQuery” aims to educate developers, reveal the magic behind jQuery, help them solve common problems without it, and give them more confidence to abandon their crutch and embrace the power of the web API and standardized JavaScript.
Reader Testimonials

Robert DiBlasi
What makes Ray's approach interesting is the way he frames the discussion of "software developer" over "library integrator" or "jQuery programmer". Libraries & frameworks are just tools. Once you know the fundamentals, then you can make smart choices about why & when you might make use of such tools. You have options as a developer. "Beyond jQuery" has a very easy to read style. I like the way Ray gives confidence to the reader that they can use JavaScript instead of a library like jQuery.
Table of Contents
-
- Acknowledgments
- Preface
- Introduction
-
I The Oppressive Magic of jQuery
-
1. Why have we been using jQuery?
- 1.1 Simplicity
- 1.2 Community
- 1.3 Habit
- 1.4 Elegance
- 1.5 Fear
-
2. A crutch is only temporary
- 2.1 You are a mechanic, not a driver
- 2.2 Stunted growth
-
3. The price of shortcuts (a true story)
- 3.1 A new direction, a new web developer
- 3.2 Shortcuts and my own stunted growth
- 3.3 A challenge – no jQuery allowed!
- 4. Focus on the implementation, not the magic
-
1. Why have we been using jQuery?
-
II You Don’t Need jQuery (anymore)
- 5. Need vs. want
-
6. Both sides of the acceptable use argument
- 6.1 When is it acceptable to use it?
- 6.2 When should you refrain from using it?
-
7. Should you use other libraries instead?
- 7.1 Small shims over large wrappers
- 7.2 Writing your own shim
- 8. The final word
-
III Understanding the Web API & “Vanilla” JavaScript
-
9. Everything you need to know about browsers
- 9.1 Ancient browsers
- 9.2 Modern browsers
- 9.3 Evergreen browsers
- 9.4 Mobile browsers
- 9.5 Non-browsers
-
10. What is this “web API” and why is it important?
- 10.1 The DOM API
- 10.2 Everything else (non-DOM)
-
11. JavaScript: A Less Elegant Version of jQuery?
- 11.1 The language versus the web API
- 11.2 History and standardization
-
9. Everything you need to know about browsers
-
IV Finding HTML Elements
-
12. Core element selectors
-
12.1 IDs
- 12.1.1 jQuery
- 12.1.2 Web API
-
12.2 Classes
- 12.2.1 jQuery
- 12.2.2 Web API
-
12.3 Element tags
- 12.3.1 jQuery
- 12.3.2 Web API
-
12.4 Pseduo-classes
- 12.4.1 jQuery
- 12.4.2 Web API
-
12.1 IDs
-
13. Selecting elements based on their relations
-
13.1 Parents and children
- 13.1.1 jQuery
- 13.1.2 Web API
-
13.2 Siblings
- 13.2.1 jQuery
- 13.2.2 Web API
-
13.3 Ancestors and descendants
- 13.3.1 jQuery
- 13.3.2 Web API
-
13.1 Parents and children
-
14. Mastering advanced element selection
-
14.1 Excluding elements
- 14.1.1 jQuery
- 14.1.2 Web API
-
14.2 Multiple selectors
- 14.2.1 jQuery
- 14.2.2 Web API
- 14.3 Element categories and modifiers
-
14.1 Excluding elements
- 15. A simple replacement for $(selector)
-
12. Core element selectors
-
V Using and Understanding HTML Element Attributes
-
16. What is an attribute?
- 16.1 History and standardization
- 16.2 How do attributes differ from properties?
-
17. Finding elements using attributes
-
17.1 Finding elements using attribute names
- 17.1.1 jQuery
- 17.1.2 Web API
-
17.2 Finding elements using attribute names and values
- 17.2.1 jQuery
- 17.2.2 Web API
-
17.3 The power of wildcard and fuzzy attribute selectors
- 17.3.1 Looking for specific characters
- 17.3.2 Looking for specific words
- 17.3.3 Attribute values that start or end with…
-
17.1 Finding elements using attribute names
-
18. Reading and modifying element attributes
-
18.1 Class attributes
- 18.1.1 Reading classes
- 18.1.2 Adding and removing classes
- 18.1.3 Toggling classes
- 18.2 Data attributes
-
18.3 Working with other standard & custom attributes
- 18.3.1 Reading attributes
- 18.3.2 Modifying attributes
-
18.1 Class attributes
-
16. What is an attribute?
-
VI HTML Element Data Storage and Retrieval
-
19. Why would you want to attach data to elements?
- 19.1 Tracking state
- 19.2 Connecting elements
- 19.3 Storing models directly in your elements
-
20. Common pitfalls of pairing data with elements
- 20.1 Memory leaks
- 20.2 Managing data
-
21. Using a solution for all browsers
-
21.1 Storing small bits of data using
data-
attributes-
21.1.1 Reading and updating
data-
attributes with jQuery -
21.1.2 Using the web API to read and update
data-
attributes
-
21.1.1 Reading and updating
-
21.2 Complex element data storage and retrieval
- 21.2.1 The familiar jQuery approach
-
21.2.2 Using a more natural approach
- 21.2.2.1 Removing data from our cache when elements are removed from the DOM
-
21.1 Storing small bits of data using
-
22. The future of element data
-
22.1 The HTML5
dataset
property -
22.2 Leveraging ES6
WeakMap
collections
-
22.1 The HTML5
-
19. Why would you want to attach data to elements?
-
VII Styling Elements
-
23. There are three ways to style elements
- 23.1 Inline styles
-
23.2 Working with styles directly on the
Element
object - 23.3 Stylesheets
-
24. Getting and setting generalized styles
- 24.1 Using jQuery
- 24.2 Without jQuery
-
25. Setting and determining element visibility
- 25.1 The typical jQuery approach
- 25.2 The native web approach
-
26. Determining width and height of any element
- 26.1 Examining an element using jQuery
-
26.2 Options natively provided by the browser
- 26.2.1 Width & height of content + padding
- 26.2.2 Width & height of content + padding + border
-
23. There are three ways to style elements
-
VIII DOM Manipulation
-
27. The DOM: A central component of web development
- 27.1 jQuery exists because of the DOM API
- 27.2 The DOM API isn’t broken, it’s just misunderstood
-
28. Moving and copying elements
-
28.1 Moving elements around the DOM
- 28.1.1 Moving elements using jQuery
- 28.1.2 The DOM API’s solution to reordering elements
- 28.2 Making copies of elements
-
28.1 Moving elements around the DOM
-
29. Composing your own elements
- 29.1 Creating and deleting elements
- 29.2 Text content
- 29.3 Rich content
-
27. The DOM: A central component of web development
-
IX Ajax Requests: Dynamic Data and Page Updates
-
30. Mastering the concepts of ajax communication
- 30.1 Async is hard
- 30.2 HTTP
- 30.3 Expected and unexpected responses
- 30.4 Web Sockets
-
31. Sending GET, POST, DELETE, PUT, and PATCH requests
- 31.1 Sending POST requests
- 31.2 Sending PUT requests
- 31.3 Sending DELETE requests
- 31.4 Sending PATCH requests
-
32. Encoding requests and reading encoded responses
- 32.1 URL encoding
- 32.2 JSON encoding
- 32.3 Multipart encoding
-
33. Uploading and manipulating files
- 33.1 Uploading files in ancient browsers
- 33.2 Uploading files in modern browsers
- 33.3 Reading and creating files
-
34. Cross-domain communication: an important topic
- 34.1 The early days (JSONP)
- 34.2 Modern times (CORS)
-
30. Mastering the concepts of ajax communication
-
X Browser Events
-
35. How do events work?
- 35.1 Event types: Custom, and native
- 35.2 Event propagation: Bubbling vs capturing
-
36. Creating and firing DOM events
- 36.1 Firing DOM events with jQuery
- 36.2 Web API DOM events
-
37. Creating and firing custom events
- 37.1 jQuery custom events
- 37.2 Firing custom events with the web API
-
38. Listening (and un-listening) to event notifications
- 38.1 jQuery event handlers
- 38.2 Observing events with the web API
- 39. Controlling event propagation
- 40. Passing data to event handlers
- 41. Event delegation: powerful and underused
-
42. Handling and triggering keyboard events
- 42.1 3 types of keyboard events
- 42.2 Identifying pressed keys
- 42.3 Making an image carousel keyboard accessible with the web API
-
43. Determining when something has loaded
- 43.1 When have all elements on the page fully loaded and rendered w/ applied styles?
- 43.2 When has all static markup been placed on the page?
- 43.3 When has a particular element on the page fully loaded? When has it failed to load?
- 43.4 Preventing a user from accidentally leaving the current page
-
44. A history lesson: Ancient browser support
- 44.1 The API for listening to events is non-standard
- 44.2 Form field change events are a minefield
-
44.3 The
Event
object is also non-standard
-
35. How do events work?
-
XI Mastering Asynchronous Tasks
-
45. Callbacks: The traditional approach for controlling async operations
- 45.1 Node.js & the error-first callback
- 45.2 Solving common problems with callbacks
-
46. Promises: An answer to async complexity
- 46.1 The first standardized way to harness async
-
46.2 Using Promises to simplify async operations
-
46.2.1 The anatomy of a
Promise
-
46.2.2 Simple
Promise
examples - 46.2.3 Fixing “callback hell” with promises
- 46.2.4 Monitoring multiple related async tasks with promises
-
46.2.1 The anatomy of a
- 46.3 jQuery’s broken promise implementation
- 46.4 Native browser support
-
47. Async functions: An abstraction for async tasks
- 47.1 The problem with promises
- 47.2 Async functions to the rescue
- 47.3 Browser support
- 48. The future of standardized async task handling
-
45. Callbacks: The traditional approach for controlling async operations
-
XII Common JavaScript Utility Functions
-
49. Working with dates, text, XML, and JSON
- 49.1 Dates
- 49.2 Converting JSON into a JavaScript object
- 49.3 Converting an XML string into a document
- 49.4 String manipulation
-
50. What kind of value is this?
- 50.1 Primitives
- 50.2 Arrays
- 50.3 Objects
- 50.4 Functions
-
51. Making JavaScript Objects bend to your will
- 51.1 Iterating over keys and values
- 51.2 Copying and merging objects
-
52. Solving problems with Arrays
- 52.1 Iterating over array items
- 52.2 Locating specific items
- 52.3 Managing pseudo-arrays
- 52.4 Mapping and merging
-
53. Useful
function
tricks- 53.1 A word about JavaScript context
- 53.2 Creating a new function from an old one
- 53.3 Calling an existing function with a new context
-
49. Working with dates, text, XML, and JSON
- About the Author
- Notes
Authors have earned$9,893,383writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
The book is almost daily updated. These incremental updates ease my interaction with the proofreaders.
Introductory Statistics with Randomization and Simulation
Mine Cetinkaya-Rundel, Christopher Barr, OpenIntro, and David DiezA complete foundation for Statistics, also serving as a foundation for Data Science, that introduces inference using randomization and simulation while covering traditional methods.
Leanpub revenue supports OpenIntro, so we can provide free desk copies to teachers interested in using our books in the classroom.
More resources: openintro.org.
Java OOP Done Right
Alan MellorObject Oriented Programming is still a great way to create clean, maintainable code. But only if you use it right.
This book gives you 25 years of OO best practice, ready to use.
You'll learn to design objects behaviour-first, use TDD to help, then confidently apply Design Patterns, SOLID principles and Refactoring to make clean, crafted code.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Composing Software
Eric ElliottAll software design is composition: the act of breaking complex problems down into smaller problems and composing those solutions. Most developers have a limited understanding of compositional techniques. It's time for that to change.
Cloud Strategy
Gregor Hohpe“Strategy is the difference between making a wish and making it come true.” A successful migration to the cloud shouldn’t be driven by wishes, but guided by a sound strategy, frameworks, and decision models. This book tells you how—without becoming superficial nor getting lost in technology and product details.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #3
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #4
CCDE Practical Studies (All labs)
3 Books
CCDE lab - #5
Modern Management Made Easy
3 Books
Read all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization. - #6
The Future of Digital Health
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer... - #7
Modern C++ by Nicolai Josuttis
2 Books
- #8
Django for Beginners/APIs/Professionals
3 Books
- #9
"The C++ Standard Library" and "Concurrency with Modern C++"
2 Books
Get my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library... - #10
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...