Posts.
-
Manipulating the DOM with event listeners
Imagine you have a dog. You'd like the dog to raise their paw and touch your hand whenever you say "shake". You'll have to teach the dog this behavior, but with enough patience (and treats!), eventually the dog will learn. You have now taught your dog (the target) to listen for a command (the event) and raise its paw (the action).
That's essentially what an event listener is. Instead of all that training though, Javascript has a method,
addEventListener()
, that provides an easy way to add all sorts of interactivity to web pages. -
Case study - Human Service Forum
The Human Service Forum is a small non-profit located in central Massachusetts. Hoping to expand their reach, they needed a website that could more reliably meet their members’ needs. After a recent redesign, they found the website’s performance disappointing (page load times were around 12 seconds) and needed help diagnosing the cause.
-
The TreeWalker.
Should you ever find yourself in need of a simple way to get a list of the nodes in your DOM, here's one way: JavaScript's
TreeWalker
.