Frameworks59k+ stars

jQuery

The library that made JavaScript bearable

Commit Details

Message
"Initial commit"
Author
John Resig
Date
2006-01-14
Hash
8a4a1adf03e98c3e8a8d8e8c8a4a1adf03e98c3e

Fun Fact

John Resig created jQuery at BarCamp NYC. It solved the nightmare of cross-browser compatibility and made AJAX accessible to everyone.

</>First Code

JavaScript
/*
 * jQuery - New Wave Javascript
 *
 * Copyright (c) 2006 John Resig (jquery.com)
 * Licensed under the MIT License
 */

function jQuery(selector, context) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init(selector, context);
}

jQuery.fn = jQuery.prototype = {
    init: function(selector) {
        // The magic: "Write less, do more"
        if (typeof selector === "string") {
            return document.querySelectorAll(selector);
        }
    },
    
    each: function(callback) {
        return jQuery.each(this, callback);
    }
};

// Revolutionized web development
window.$ = window.jQuery = jQuery;