Comparison of jQuery methods and their native JavaScript counterparts; jQuery and core JS performance comparison; and ways to use only the parts of jQuery you need.
Saying Goodbye to jQuery and Hello to Native JavaScript Selectors, Events, and More
1. SO LONG, JQUERY, AND THANKS FOR
ALL THE FISH!
MATT TURNURE
github.com/MattTurnure
@MattTurnure
mattturnure.com
2. I LOVE NATIVE, CORE JAVASCRIPT BECAUSE …
1. We are living in modern times.
Support for older browsers are dwindling.
2. It’s more performant.
Core JavaScript is faster than jQuery in many cases.
3. jQuery uses it.
3. THINGS I HAVE USED JQUERY FOR
1. Selectors
2. Class Manipulation
3. Loops
4. Event Modeling
5. Animation
6. Ajax
16. BROWSER SUPPORT
< IE8 is not supported. IE8 has partial support. Partial support in
IE8 is due to being limited to CSS 2.1 selectors. Additionally, it will
have trouble with selectors including unrecognized tags (for
example HTML5 ones).
http://caniuse.com/#search=querySelectorAll
http://caniuse.com/#search=getElementsByClassName
FURTHER READING
https://developer.mozilla.org/en-
US/docs/Web/API/Document.querySelectorAll
https://developer.mozilla.org/en-
US/docs/Web/API/document.getElementsByClassName
https://developer.mozilla.org/en-
US/docs/Web/API/document.getElementById
30. BROWSER SUPPORT
<= IE9 and Opera Mini not supported
http://caniuse.com/#search=classList
FURTHER READING
https://developer.mozilla.org/en-
US/docs/Web/API/Element.classList
33. $.each()
var $list = $('ul li');
$.each($list, function (i, val) {
// do something with val
});
34. arr.forEach()
var list = document.querySelectorAll('ul li'),
ary = Array.prototype.slice.call(list);
ary.forEach(function (item) {
// do something with item
});
39. $el.on()
var $list = $('#list');
function func() {}
$list.on('click', func);
$list.off('click', func);
40. el.addEventListener()
var list = document.getElementById('list');
function func() {}
list.addEventListener('click', func, false);
list.removeEventListener('click', func, false);
44. AJAX
Only use the parts of jQuery that you need.
https://github.com/jquery/jquery
$ grunt custom:-core/ready,-css,-effects,-deprecated,-dimensions,-event/alias,-offset,-wrap