WHAT CAN LIBRARIES DO

Course- Javascript >

The specifics differ depending on the library concerned and the needs and intentions of its creator. However, there are certain recurring themes that most libraries include:

  • Encapsulation of DOM methods—As you see later in this section when you look at prototype.js, JavaScript libraries can offer appealing shorthand ways to select and manage page elements and groups of elements.
  • Animation—In Section JAVASCRIPT CONTROL STATEMENT, “Program Control,” you learned about the use of timers. Timers can be used to animate page elements, but writing such code can be tricky and the resulting code complicated to maintain. Many of the popular libraries wrap these sorts of operations into convenient functions to slide, fade, shake, squish, fold, snap, and pulsate parts of your page’s interface, all in a crossbrowser way and with just a few lines of code.
  • Drag and drop—A truly cross-browser drag and drop has always been one of the trickiest effects to code for all browsers. Libraries can make it easy.
  • Ajax—Easy methods to update page content without needing to worry about the nitty-gritty of instantiating XMLHttpRequest objects and managing callbacks and status codes.