jQuery unveiled: library constants

jQuery constants are actually private properties used throughout the library. They're as follows:

    // Map over jQuery in case of overwrite
 _jQuery = window.jQuery,

 // Map over the $ in case of overwrite
 _$ = window.$,

 // Use the correct document accordingly with window argument (sandbox)
 document = window.document,

 // A central reference to the root jQuery(document)
 rootjQuery,

 // A simple way to check for HTML strings or ID strings
 // (both of which we optimize for)
 quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,

 // Is it a simple selector
 isSimple = /^.[^:#\[\.,]*$/,

 // Check if a string has a non-whitespace character in it
 rnotwhite = /\S/,

 // Used for trimming whitespace
 rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,

 // Match a standalone tag
 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,

 // Keep a UserAgent string for use with jQuery.browser
 userAgent = navigator.userAgent,

 // For matching the engine and version of the browser
 browserMatch,
 
 // Has the ready events already been bound?
 readyBound = false,
 
 // The functions to execute on DOM ready
 readyList = [],

 // The ready event handler
 DOMContentLoaded,

 // Save a reference to some core methods
 toString = Object.prototype.toString,
 hasOwnProperty = Object.prototype.hasOwnProperty,
 push = Array.prototype.push,
 slice = Array.prototype.slice,
 indexOf = Array.prototype.indexOf;

  1. _jQuery – serves as an internal reference to the jQuery wrapper
  2. _$ – creates an internal reference to the jQuery alias $
  3. document – is a link to the document object; it uses the window.document notation to avoid scope problems
  4. rootjQuery – is a reference to the root jQuery, that is, the whole document object
  5. quickExpr – is a regular expression used to match against HTML strings and ID; note that jQuery makes use of regular expressions to implement its internal element selection based on CSS selectors
  6. isSimple – a regular expression that matches a simple selector
  7. rnotwhite, rtrim – handle white-space
  8. rsingleTag – matches a standalone HTML tag
  9. userAgent – a reference to the navigator.userAgent property
  10. browserMatch – matches the engine and version of the browser
  11. readyBound – a boolean value used to check if a ready event has already been triggered
  12. readyList – an array that contains a list of functions to be initialized when the DOM is ready
  13. DOMContentLoaded – see https://developer.mozilla.org/en/Gecko-Specific_DOM_Events
  14. toString, hasOwnProperty, push, slice, indexOf – a reference to JavaScript core methods that will be overwritten.

This entry was posted in by Gabriele Romanato. Bookmark the permalink.

Leave a Reply

Note: Only a member of this blog may post a comment.