Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The Benefits of Vanilla JavaScript (for the jQuery Developer)
Search
Nate Conley
September 12, 2017
Technology
0
130
The Benefits of Vanilla JavaScript (for the jQuery Developer)
Nate Conley
September 12, 2017
Tweet
Share
More Decks by Nate Conley
See All by Nate Conley
wp_enqueue_scripts
nateconley
0
40
webpack for WordPress
nateconley
0
140
Other Decks in Technology
See All in Technology
AI JIMY - 登壇(インストール編)
hanacchi
0
150
データベース05: SQL(2/3) 結合質問
trycycle
0
120
社内での継続的な機械学習勉強会の開催のコツ
yudai00
2
410
QA Engineer Life @ LINE
line_developers_tw
PRO
0
170
複雑なビジネスルールに挑む:正確性と効率性を両立するfp-tsのチーム活用術 / Strike a balance between correctness and efficiency with fp-ts
kakehashi
5
3.7k
ハードウェアを動かすTypeScriptの世界
9wick
3
1.2k
生成AIと産業向けソフトウェアの自動生成 〜 ハノーバーメッセ2024より〜
kioto
2
450
Taking Flight with Tailwind CSS
opdavies
0
4.3k
グイグイ系QAエンジニアでやっていくよ!
____rina____
0
790
SRE活動を促進させるドキュメント技術 〜ドキュメントレビューって、どうやってる?〜
kenta_hi
0
100
[PyconUS 2024] Having fun with Pydantic and pattern matching
enforcerpl
0
200
テストコードを書きながらCompose Multiplatformを乗りこなす
subroh0508
0
150
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
60
4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
84
45k
A better future with KSS
kneath
231
16k
Debugging Ruby Performance
tmm1
70
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
22
6.5k
Making the Leap to Tech Lead
cromwellryan
125
8.6k
A Philosophy of Restraint
colly
197
16k
The Cost Of JavaScript in 2023
addyosmani
21
4k
YesSQL, Process and Tooling at Scale
rocio
165
13k
Making Projects Easy
brettharned
109
5.6k
GitHub's CSS Performance
jonrohan
1025
450k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
Transcript
The Benefits of Vanilla JavaScript WordCamp Sacramento 2017 1 (for
the jQuery Developer)
Hi, I’m Nate
I have a confession
I ♥ jQuery
but… sometimes I use it as a crutch
jQuery is awesome!
What do I mean by Vanilla JavaScript?
Why should I even learn Vanilla JavaScript?
Because Matt said so…
Knowing jQuery != Knowing JavaScript
Performance
operations/second Vanilla document.getElementById( ‘app’ ); 12,137,211 jQuery $( ‘#app’ )
350,557 http://vanilla-js.com/
One less dependency to load in the browser
The Future
jQuery Browser Support 1.12.4 (WordPress) - Support for IE6+ 15
3.2.1 (Current) - Support for IE9+
Fancy Frameworks and Libraries
You Might Not Need jQuery…
How Can I Start?
DOM
Selecting DOM Elements $( ‘.some-selector #here’ )
Selecting DOM Elements document.getElementById() document.querySelector() document.querySelectorAll() - Get one element
by ID selector - Get one element by CSS-like selector - Get all elements by CSS-like selector
Selecting DOM Elements document.getElementsByClassName() document.getElementsByName() document.getElementsByTagName() - Get all elements
by class selector - Get all elements by name attribute - Get all elements by HTML tag
Creating DOM Elements document.createElement() element.cloneNode() element.appendChild() - Create an element
by passing it an HTML tag - Clone an element - Append a child
More DOM Topics Traversing the DOM Form Manipulation Styles element.parentNode.firstChild
getSiblings( element ) element.value element.style.backgroundColor = ‘red’
Events
addEventListener Similar to .on(), .click(), etc. in jQuery element.addEventListener( ‘click’,
function() { // Do something } );
AJAX
XMLHttpRequest (XHR) is UGLY
var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if
( xhr.readyState == 4 && xhr.status == 200 ) { // Do something } } xhr.open( ‘GET’, ‘/wp-json/wp/v2/posts’, true ); xhr.send();
Fetch API Supported in major browsers, but no IE11 davidwalsh.name/fetch
fetch( '/wp-json/wp/v2/posts', { method: ‘GET' } ) .then( function( response ) { // Do something } ) .catch( function( error ) { // Do something } );
Live Coding! github.com/nateconley/vanilla-js
Learn More • JavaScript 30 - wesbos.com/javascript30 • Plain JS
- plainjs.com • JavaScript for WordPress - javascriptforwp.com • You Might Not Need jQuery - youmightnotneedjquery.com
Learn More • From jQuery to JavaScript - code.tutsplus.com/ tutorials/from-jquery-to-javascript-a-reference--
net-23703 • Sans jQuery - gist.github.com/joyrexus/7307312 • Wes Bos Resources - wesbos.com/learn-javascript/ • Parallax Done Right - medium.com/@dhg/parallax- done-right-82ced812e61c
@nateconley123 nateconley.com