jQuery Alternatives
  • · Do You Really Need jQuery? []
    In 2013, the top five browsers are closer than ever. The core JavaScript tenets of DOM traversal, manipulation, event handling, server communication and CSS effects are well implemented and documented. So why use a library when the problems it solves no longer exist?
    If you use a CDN, those routines will be delivered a lot faster than your own homegrown versions. And that assumes they haven't already been downloaded and cached when the user visited some other web site.
  • For example, querySelector and querySelectorAll vs $(). But, you lose parent, filter, find, etc.
  • · Build your own jQuery []
    Special builds can be created that exclude subsets of jQuery functionality. This allows for smaller custom builds. Any module may be excluded except for core, and selector. As a special case, you may also replace Sizzle (when excluded, it's replaced by a rudimentary selector engine based on the browser's querySelectorAll).
  • · Vanilla JS []
    Vanilla JS is a fast, lightweight, cross-platform framework for building incredible, powerful JavaScript applications. Final size: 0 bytes uncompressed, 25 bytes gzipped. LOL -I will admit: I looked at the page and was very interested and got super excited until I looked at the code examples harder. Well played, internet... well played.
jQuery Summary

The document.ready Event

The JQuery document.ready event fires as soon as the DOM has loaded (which is before images have loaded). This function can be called multiple times (JQuery will chain them all together).
  1. $(document).ready(function() {    
  2.   console.log("DOM has loaded");    
  3. });  
Alternate form:
  1. $(function() {  
  2.   console.log("DOM has loaded");    
  3. });  

Bind to an Event Handler

How to bind an event handler to the "click" event.
  1. // .click( handler(eventObject) )    
  2. $(document).ready(function() {    
  3.   // register a click-event handler    
  4.   $("_SELECTOR_").click(function(event) {    
  5.     // log the id of the clicked element    
  6.     console.log(;    
  7.   });    
  8. });    

Handle an Event

How to get an attribute from the JQuery object that was clicked during a click event.
  1. $(document).ready(function(){  
  2.   // register a click-event handler  
  3.   $("_SELECTOR_").click(function() {
  4.     // get the JQuery object for the clicked element, then get its class attribute  
  5.     var styleClass = $(this).attr("class");  
  7.     console.log(styleClass);  
  8.   });  
  9. });