Skip to content

Instantly share code, notes, and snippets.

@dungvtdev
Created February 3, 2017 03:16
Show Gist options
  • Save dungvtdev/0dfc524d4bce87b09bd3c55bbd111c65 to your computer and use it in GitHub Desktop.
Save dungvtdev/0dfc524d4bce87b09bd3c55bbd111c65 to your computer and use it in GitHub Desktop.
Javascript benmark and experiences
var c = $("#comments .comment"); // 4,649 ms
// jQuery 2.0
var c = $(".comment"); // 3,437 ms
// native querySelectorAll
var c = document.querySelectorAll("#comments .comment"); // 1,362 ms
// native querySelectorAll
var c = document.querySelectorAll(".comment"); // 1,168 ms
// native getElementById / getElementsByClassName
var n = document.getElementById("comments");
var c = n.getElementsByClassName("comment"); //107 ms
// native getElementsByClassName
var c = document.getElementsByClassName("comment"); //75 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment