Created
February 3, 2014 16:28
-
-
Save vongillern/8787103 to your computer and use it in GitHub Desktop.
Why you probably do want jQuery....
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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