Skip to content

Instantly share code, notes, and snippets.

@tylucaskelley
Last active October 11, 2015 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylucaskelley/b9b868ce4ad6cf22c764 to your computer and use it in GitHub Desktop.
Save tylucaskelley/b9b868ce4ad6cf22c764 to your computer and use it in GitHub Desktop.
Udacity jQuery Webcast: When Does Sizzle Get Used?
$(document).ready(function() {
// Sizzle is jQuery's internal library for DOM element selection. When does it actually get used?
// modern browser, i.e. Chrome, Firefox, Safari, IE 8+, Edge
$("#title"); // Nope! --> document.getElementById("title");
$(".my-class") // Nope! --> document.getElementsByClassName("my-class");
$("body > div.foo #element"); // Nope! --> document.querySelectorAll("body > div.foo #element");
// IE 6,7 and other outdated browsers
$("#title"); // Nope! --> document.getElementById("title");
$(".my-class") // Nope! --> document.getElementsByClassName("my-class");
$("body > div.foo #element"); // Yes! Here, we need Sizzle, since we don't have the querySelectorAll function.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment