Skip to content

Instantly share code, notes, and snippets.

@vongillern
Created February 3, 2014 16:28
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 vongillern/8787103 to your computer and use it in GitHub Desktop.
Save vongillern/8787103 to your computer and use it in GitHub Desktop.
Why you probably do want jQuery....
/*
http://youmightnotneedjquery.com/ has been a topic of recent discussion lately. It has an interesting point,
but I was curious how much code you don't have to write when using jQuery vs native js
Here is the output of the following code when run against youmightnotneedjquery.com
jquery total length: 6,174
ie8 total length: 11,223
not using jquery almost DOUBLES the code you have to write.
(output formated for readability)
*/
/* if you want to run this yourself, make sure you add a reference to jquery, they don't have one ;) */
$(function () {
var jqTotalLength = 0;
var ie8TotalLength = 0;
$(".jquery").each(function(i, e) {
jqTotalLength += $(e).text().length
})
$(".ie8").each(function(i, e) {
ie8TotalLength += $(e).text().length
})
console.log("jquery total length: " + jqTotalLength);
console.log("ie8 total length: " + ie8TotalLength);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment