SlideShare a Scribd company logo
Ditching JQuery
Hao Luo
Northwestern University
https://joind.in/16012
Ditching JQuery - Hao Luo - Madison PHP
Intro
2
4 years as a full-time web developer
@howlowck
haowebdev@gmail.com
Ditching JQuery - Hao Luo - Madison PHP
I ❤ JQuery
•One codebase, all the browser!
•Introduced me to JavaScript
•“It just works”
3
Ditching JQuery - Hao Luo - Madison PHP
Goal of This Talk
•Not to convince anyone
•Important to understand the basics
•Lessen the hurdle to start using pure JavaScript
4
Ditching JQuery - Hao Luo - Madison PHP5
Scenario Problem
Ditching JQuery - Hao Luo - Madison PHP
Our Late Stay Requirements
Admin can…
•See a list of applications with some information
•Can decide to approve or deny an application
•Can delete an application
•Can add a random application
6
Ditching JQuery - Hao Luo - Madison PHP
IE9 Demo
7
github.com/howlowck/latestay-purejs
github.com/howlowck/latestay-jquery
Ditching JQuery - Hao Luo - Madison PHP
Late Stay Workflow
8
HTTP GET latestayapp.com/purejs
HTML (empty ul#applications container)
AJAX GET latestayapp.com/applications
JSON (parses then inserts in #applications container)
(admin clicks on the approve button)
AJAX PUT latestayapp.com/applications/20/approve
JSON (update HTML)
AJAX
DOM
Events
Ditching JQuery - Hao Luo - Madison PHP
DOM
Querying, Traversal, and Manipulation
9
Ditching JQuery - Hao Luo - Madison PHP
Some DOM Operations
10
JQuery Vanilla JS
$(‘#application-20’); document.querySelector(‘#application-20’);
$el.attr(‘data-id’,	‘20’);	
$el.attr(‘data-id’);
el.setAttribute(‘data-id’,	‘20’);	
el.getAttribute(‘data-id’);
yes yes yes 9+
yes yes yes yes
yes yes yes 10+$el.addClass(‘approved’);	
$el.removeClass(‘approved’);	
$el.toggleClass(‘approved’);
el.classList.add(‘approved’);	
el.classList.remove(‘approved’);	
el.classList.toggle(‘approved’);
$el.data(‘id’,	‘20’);	
var	id	=	$el.data(‘id’);
el.dataset.id	=	‘20’;	
var	id	=	el.dataset.id; yes yes yes 11+
$button.closest(‘.application’); button.closest(‘.application’); 41 35 no no
https://dom.spec.whatwg.org/#dom-element-closestselectors
https://github.com/eligrey/classList.js/
Ditching JQuery - Hao Luo - Madison PHP
Polyfills
11
A polyfill is a piece of code that provides the technology that the developer expects the
browser to provide natively. Flattening the API landscape if you will. - Remy Sharp
var	ELEMENT	=	Element.prototype;	
ELEMENT.matches	=	ELEMENT.matches	
				||	ELEMENT.msMatchesSelector	
				||	ELEMENT.mozMatchesSelector	
				||	ELEMENT.webkitMatchesSelector;	
ELEMENT.closest	=	ELEMENT.closest		
				||	function	(selector)	{	
								var	node	=	this;	
								while	(node)	{	
												if	(node.matches(selector))	{	
																break;	
												}	
												node	=	node.parentElement;	
								}	
								return	node;	
};	
41 35 no no
yes yes yes 9+
<li	class="application"	id=“#application-20">	
…	
				<div	class="action-bar">	
								<div	class=“action">	
…	
												<button	class="delete">	
								</div>	
				</div>	
</li>	
deleteButton.closest('.application');	
HTML
Javascript
Javascript
Ditching JQuery - Hao Luo - Madison PHP
DOM Events
12
Ditching JQuery - Hao Luo - Madison PHP13
Register Event Callbacks
Yes Yes Yes 9+
JQuery $('.delete').on('click',	deleteApplication);
Vanilla JS
getAllElToArr('.delete').forEach(function	(el)	{	
			el.addEventListener('click',	deleteApplication);	
});
Ditching JQuery - Hao Luo - Madison PHP
li.application ☺☹ ✖li.application ☺☹ ✖
Direct Events (vs Delegated
Events)
14
li.application
li.application
li.application
div#application-container
ul#applications
li.application
JQuery
$('.delete').on('click',	deleteApplication);	
Vanilla JS
getAllElToArr('.delete').forEach(function	(el)	{	
			el.addEventListener('click',	deleteApplication);	
});	
EventListener #1
EventListener #4
EventListener #3
EventListener #2
EventListener #5
EventListener #6
✖
✖
✖
✖
Ditching JQuery - Hao Luo - Madison PHP
li.application ☺☹ ✖
Delegated Events
15
li.application
li.application
li.application
div#application-container
ul#applications
li.application
li.application ☺☹ ✖
JQuery
$(‘ul.applications’).on(‘click’,	‘.deleteBtn’,	
deleteApplication);
Vanilla JS No	Standard	for	Event	Delegation	:(✖
✖
✖
✖
EventListener #1
is the ‘click’ target element the ‘.delete’ button? 

if so, run deleteApplication
is the ‘click’ target element the ‘.approve’ button? 

if so, run approveApplication
https://github.com/ftlabs/ftdomdelegate
Ditching JQuery - Hao Luo - Madison PHP
AJAX
16
Ditching JQuery - Hao Luo - Madison PHP
AJAX
17
JQuery $.ajax();
Vanilla JS XMLHttpRequest
HTML5 Fetch	API
yes yes yes yes
41 no no no
Fetch API Polyfill: https://github.com/github/fetch
yes yes yes 9+
Ditching JQuery - Hao Luo - Madison PHP
POST - A Closer Look
18
JQuery XMLHttpRequest
$.ajax('/applications',	{	
		method:	'POST',	
		contentType:	'application/json',	
		processData:	false,	
		data:	JSON.stringify({	
						name:	'Joe	Bob',	
						reason:	'Too	cold	outside'	
		})	
})	
.then(function	success(application)	{	
		appendApplicationHTML(application);	
})	
.fail(function	failed()	{	
		console.log('request	failed!');	
});	
xhr	=	new	XMLHttpRequest();	
xhr.open('POST',	'/applications'));	
xhr.setRequestHeader('Content-Type',	'application/json');	
xhr.onload	=	function()	{	
				if	(xhr.status	===	200)	{	
									var	applicationInfo	=	JSON.parse(xhr.responseText);	
						appendApplicationHTML(application);	
				}	
				else	if	(xhr.status	!==	200)	{	
								alert('Request	failed.	');	
				}	
};	
xhr.send(JSON.stringify({	
				name:	'Joe	Bob',	
				reason:	'Too	cold	outside'	
});
Ditching JQuery - Hao Luo - Madison PHP
POST - A Closer Look
19
JQuery Fetch API
$.ajax('/applications',	{	
		method:	'POST',	
		contentType:	'application/json',	
		processData:	false,	
		data:	JSON.stringify({	
						name:	'Joe	Bob',	
						reason:	'Too	cold	outside'	
		})	
})	
.then(function	success(application)	{	
		appendApplicationHTML(application);	
})	
.fail(function	failed()	{	
		console.log('request	failed!');	
});	
fetch('/users',	{	
		method:	'post',	
		headers:	{	
				'Content-Type':	'application/json'	
		},	
		body:	JSON.stringify({	
				name:	'Joe	Bob',	
				reason:	'Too	Cold	Outside'	
		})	
})	
.then(function	(response)	{	
		return	response.json();	
})	
.then(function	(application)	{	
		appendApplicationHTML(application);	
})	
.catch(function(error)	{	
		console.log('request	failed',	error);	
});
Ditching JQuery - Hao Luo - Madison PHP
DeferredValue
Eliminates Callback hell
Offers More Flexibility and Freedom
Promises are awesome
20
Ditching JQuery - Hao Luo - Madison PHP
Utilities
21
Ditching JQuery - Hao Luo - Madison PHP
DOM Loaded
22
JQuery Vanilla JS
$(function(event)	{	
		console.log("DOM	fully	loaded	and	parsed");	
});	
document.addEventListener("DOMContentLoaded",	
function(event)	{	
				console.log("DOM	fully	loaded	and	parsed");	
		});	
yes yes yes 9+
Don’t use "load"
Ditching JQuery - Hao Luo - Madison PHP
HTML Parse
23
JQuery Vanilla JS
var	el	=	$.parseHTML(HTMLString);
var	parser	=	new	DOMParser();		
var	doc	=	parser.parseFromString(HTMLString,	'text/html');		
var	el	=	doc.body.firstChild;	
30 12 7.1 10+
function	parseHTML	(str)	{	
		var	tmp	=	document.implementation.createHTMLDocument('');	
		tmp.body.innerHTML	=	str;	
		return	tmp.body.firstChild;	
};	
IE9 won’t accept empty param
yes yes yes 9+
Ditching JQuery - Hao Luo - Madison PHP
Date Parse
IE9 needs W3C output (which is also ISO 8601
compliant) (http://www.w3.org/TR/NOTE-
datetime-970915.html)
24
<?php	
$objDateTime	=	new	DateTime('NOW');	
echo	$objDateTime->format('c');															//	1975-12-25T14:15:16-05:00	Yes	IE9	
echo	$objDateTime->format(DateTime::ISO8601);	//	1975-12-25T14:15:16-0500		No	IE9
Ditching JQuery - Hao Luo - Madison PHP
A word about JQuery Animate
•Use Semantic HTML
•Use CSS Transition
25
.application	{	
				opacity:	1;	
				max-height:	300px;	
				transition:	max-height	0.5s,	opacity	0.7s;	
}	
.application.removed	{	
				max-height:	0;	
				opacity:	0;	
}	
CSS
Ditching JQuery - Hao Luo - Madison PHP
Closing Thoughts
26
Ditching JQuery - Hao Luo - Madison PHP27
Non-Technical Reasons
• a lot of magic is confusing sometimes
• Understanding the basics makes you a better
developer
$('div');	//creates	a	jquery	instance	with	the	selection	inside	
$('<div>');	//creates	a	jquery	instance	with	a	new	element	not	in	document	
$($aJQueryInstance);	//makes	a	clone	of	$aJQueryInstance	
$(function()	{})	//registers	function	to	run	after	DOM	is	loaded	
$({foo:	'bar'});	//???	creates	a	jquery	set	that	has	a	subset	of	methods	???	
var	$appsEl1	=	$('#applications');	
var	$appsEl2	=	$('#applications');	
$appsEl1	===	$appsEl2;	//false	
var	appsEl1	=	document.querySelector('#applications');	
var	appsEl2	=	document.querySelector('#applications');	
appsEl1	===	appsEl2;	//true
Ditching JQuery - Hao Luo - Madison PHP
Some Takeaways
•Avoid monolithic libraries & frameworks and Use
Packages and Polyfills
•Out of the JQuery Plugin Ecosystem and into NPM or
Bower
•Browser and Server
28
Ditching JQuery - Hao Luo - Madison PHP
When to use JQuery
•When you have to support IE8
•When you don’t have CORS
•Abstractions sometimes are good!
29
uses requestAnimationFrames	for	its	animationsuses setInterval	for	its	animations
Ditching JQuery - Hao Luo - Madison PHP
Resources for DOM references
http://blog.garstasio.com/you-dont-need-jquery/
http://youmightnotneedjquery.com/
http://html5please.com/
30
Ditching JQuery - Hao Luo - Madison PHP
Thank you!
@howlowck
https://joind.in/16012
31

More Related Content

What's hot

Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
singingfish
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
Hannes Hapke
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
Anis Ahmad
 
Seven Reasons for Code Bloat
Seven Reasons for Code BloatSeven Reasons for Code Bloat
Seven Reasons for Code Bloat
Christian Heilmann
 
React mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche EheReact mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche Ehe
inovex GmbH
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
Addy Osmani
 
plumbing for the next web
plumbing for the next webplumbing for the next web
plumbing for the next web
Ian Forrester
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
Neil Crosby
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
Mek Srunyu Stittri
 
Turbogears Presentation
Turbogears PresentationTurbogears Presentation
Turbogears Presentation
didip
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
Your code are my tests
Your code are my testsYour code are my tests
Your code are my tests
Michelangelo van Dam
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
Automation Abstractions: Page Objects and Beyond
Automation Abstractions: Page Objects and BeyondAutomation Abstractions: Page Objects and Beyond
Automation Abstractions: Page Objects and Beyond
TechWell
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
Arnauld Loyer
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
ทวิร พานิชสมบัติ
 
What is HTML 5?
What is HTML 5?What is HTML 5?
What is HTML 5?
Susan Winters
 
Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer
0983676660
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
WSO2
 
Node.JS error handling best practices
Node.JS error handling best practicesNode.JS error handling best practices
Node.JS error handling best practices
Yoni Goldberg
 

What's hot (20)

Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
 
Create responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJSCreate responsive websites with Django, REST and AngularJS
Create responsive websites with Django, REST and AngularJS
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
Seven Reasons for Code Bloat
Seven Reasons for Code BloatSeven Reasons for Code Bloat
Seven Reasons for Code Bloat
 
React mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche EheReact mit TypeScript – eine glückliche Ehe
React mit TypeScript – eine glückliche Ehe
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
 
plumbing for the next web
plumbing for the next webplumbing for the next web
plumbing for the next web
 
Automated Frontend Testing
Automated Frontend TestingAutomated Frontend Testing
Automated Frontend Testing
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 
Turbogears Presentation
Turbogears PresentationTurbogears Presentation
Turbogears Presentation
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Your code are my tests
Your code are my testsYour code are my tests
Your code are my tests
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Automation Abstractions: Page Objects and Beyond
Automation Abstractions: Page Objects and BeyondAutomation Abstractions: Page Objects and Beyond
Automation Abstractions: Page Objects and Beyond
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
 
What is HTML 5?
What is HTML 5?What is HTML 5?
What is HTML 5?
 
Lt web quiz_answer
Lt web quiz_answerLt web quiz_answer
Lt web quiz_answer
 
Rapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 PlatformRapid Application Development with WSO2 Platform
Rapid Application Development with WSO2 Platform
 
Node.JS error handling best practices
Node.JS error handling best practicesNode.JS error handling best practices
Node.JS error handling best practices
 

Viewers also liked

Lesson 40 philippians, colossians, philemon
Lesson 40   philippians, colossians, philemonLesson 40   philippians, colossians, philemon
Lesson 40 philippians, colossians, philemon
David Mortensen
 
今時のバンド
今時のバンド今時のバンド
今時のバンド
Ryu Seino
 
International MBA
International MBAInternational MBA
International MBA
Alexandre Latorre
 
What is Windows 10?
What is Windows 10?What is Windows 10?
What is Windows 10?
hewie
 
Gotween special press release
Gotween special press releaseGotween special press release
Gotween special press release
David Silverman
 
Espacio
EspacioEspacio
Chavinde huatar
Chavinde huatarChavinde huatar
Chavinde huatar
Diego De Castro Araujo
 
Tested by Fire (presentation)
Tested by Fire (presentation)Tested by Fire (presentation)
Tested by Fire (presentation)
Ben Santiago
 
Beseda življenja 2015-11
Beseda življenja 2015-11Beseda življenja 2015-11
Beseda življenja 2015-11
Borut Spanovic
 
Present simple explanation
Present simple explanationPresent simple explanation
Present simple explanation
Alexandra Bolaños
 
Tobiii gym
Tobiii gymTobiii gym
Tobiii gym
Tobi Gonzalez
 
poverty in pakistan
poverty in pakistanpoverty in pakistan
poverty in pakistan
kamran khan
 
Line graph
Line graphLine graph
Line graph
Emilijim
 
Ewolucja architektury Getresponse Api
Ewolucja architektury Getresponse ApiEwolucja architektury Getresponse Api
Ewolucja architektury Getresponse Api
Michal Giergielewicz
 
Tuskegee University triple major grad thankful for his journey
Tuskegee University triple major grad thankful for his journeyTuskegee University triple major grad thankful for his journey
Tuskegee University triple major grad thankful for his journeyDavid Billingslea
 
Microeconomia
MicroeconomiaMicroeconomia
Microeconomia
Geovita Aguirre León
 
Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...
Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...
Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...
Jonathan Mawdsley
 
Bai giang hinh hoa 2
Bai giang hinh hoa 2Bai giang hinh hoa 2
Bai giang hinh hoa 2
kekktt
 
Dosearches virus removal
Dosearches virus removalDosearches virus removal
Dosearches virus removal
sakthiprime2
 

Viewers also liked (20)

Lesson 40 philippians, colossians, philemon
Lesson 40   philippians, colossians, philemonLesson 40   philippians, colossians, philemon
Lesson 40 philippians, colossians, philemon
 
今時のバンド
今時のバンド今時のバンド
今時のバンド
 
International MBA
International MBAInternational MBA
International MBA
 
What is Windows 10?
What is Windows 10?What is Windows 10?
What is Windows 10?
 
Gotween special press release
Gotween special press releaseGotween special press release
Gotween special press release
 
event booklet 3
event booklet 3event booklet 3
event booklet 3
 
Espacio
EspacioEspacio
Espacio
 
Chavinde huatar
Chavinde huatarChavinde huatar
Chavinde huatar
 
Tested by Fire (presentation)
Tested by Fire (presentation)Tested by Fire (presentation)
Tested by Fire (presentation)
 
Beseda življenja 2015-11
Beseda življenja 2015-11Beseda življenja 2015-11
Beseda življenja 2015-11
 
Present simple explanation
Present simple explanationPresent simple explanation
Present simple explanation
 
Tobiii gym
Tobiii gymTobiii gym
Tobiii gym
 
poverty in pakistan
poverty in pakistanpoverty in pakistan
poverty in pakistan
 
Line graph
Line graphLine graph
Line graph
 
Ewolucja architektury Getresponse Api
Ewolucja architektury Getresponse ApiEwolucja architektury Getresponse Api
Ewolucja architektury Getresponse Api
 
Tuskegee University triple major grad thankful for his journey
Tuskegee University triple major grad thankful for his journeyTuskegee University triple major grad thankful for his journey
Tuskegee University triple major grad thankful for his journey
 
Microeconomia
MicroeconomiaMicroeconomia
Microeconomia
 
Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...
Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...
Mawdsley & Carter 2015 - DC Bombus pensylvanicus - The Maryland Entomologist ...
 
Bai giang hinh hoa 2
Bai giang hinh hoa 2Bai giang hinh hoa 2
Bai giang hinh hoa 2
 
Dosearches virus removal
Dosearches virus removalDosearches virus removal
Dosearches virus removal
 

Similar to Ditching jQuery Madison

Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
howlowck
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
Nagaraju Sangam
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Jquery tutorial
Jquery tutorialJquery tutorial
Jquery tutorial
Bui Kiet
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
Richard McIntyre
 
Think jQuery
Think jQueryThink jQuery
Think jQuery
Ying Zhang
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
dmethvin
 
Jquery
JqueryJquery
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web Technologies
Perttu Myry
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
Haehnchen
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
Darwin Biler
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
chartjes
 
HTTP Potpourri
HTTP PotpourriHTTP Potpourri
HTTP Potpourri
Kevin Hakanson
 
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Peter Martin
 
Basic Tutorial of React for Programmers
Basic Tutorial of React for ProgrammersBasic Tutorial of React for Programmers
Basic Tutorial of React for Programmers
David Rodenas
 
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Jamie Matthews
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
Jose Manuel Pereira Garcia
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Patrick Meenan
 
J Query
J QueryJ Query
J Query
ravinxg
 

Similar to Ditching jQuery Madison (20)

Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Jquery tutorial
Jquery tutorialJquery tutorial
Jquery tutorial
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
Think jQuery
Think jQueryThink jQuery
Think jQuery
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
Jquery
JqueryJquery
Jquery
 
Modern Web Technologies
Modern Web TechnologiesModern Web Technologies
Modern Web Technologies
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4Building Large Scale PHP Web Applications with Laravel 4
Building Large Scale PHP Web Applications with Laravel 4
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
HTTP Potpourri
HTTP PotpourriHTTP Potpourri
HTTP Potpourri
 
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
 
Basic Tutorial of React for Programmers
Basic Tutorial of React for ProgrammersBasic Tutorial of React for Programmers
Basic Tutorial of React for Programmers
 
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
 
From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)From Legacy to Hexagonal (An Unexpected Android Journey)
From Legacy to Hexagonal (An Unexpected Android Journey)
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...Google I/O 2012 - Protecting your user experience while integrating 3rd party...
Google I/O 2012 - Protecting your user experience while integrating 3rd party...
 
J Query
J QueryJ Query
J Query
 

Recently uploaded

E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
Drona Infotech
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 

Recently uploaded (20)

E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
Mobile app Development Services | Drona Infotech
Mobile app Development Services  | Drona InfotechMobile app Development Services  | Drona Infotech
Mobile app Development Services | Drona Infotech
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 

Ditching jQuery Madison

  • 1. Ditching JQuery Hao Luo Northwestern University https://joind.in/16012
  • 2. Ditching JQuery - Hao Luo - Madison PHP Intro 2 4 years as a full-time web developer @howlowck haowebdev@gmail.com
  • 3. Ditching JQuery - Hao Luo - Madison PHP I ❤ JQuery •One codebase, all the browser! •Introduced me to JavaScript •“It just works” 3
  • 4. Ditching JQuery - Hao Luo - Madison PHP Goal of This Talk •Not to convince anyone •Important to understand the basics •Lessen the hurdle to start using pure JavaScript 4
  • 5. Ditching JQuery - Hao Luo - Madison PHP5 Scenario Problem
  • 6. Ditching JQuery - Hao Luo - Madison PHP Our Late Stay Requirements Admin can… •See a list of applications with some information •Can decide to approve or deny an application •Can delete an application •Can add a random application 6
  • 7. Ditching JQuery - Hao Luo - Madison PHP IE9 Demo 7 github.com/howlowck/latestay-purejs github.com/howlowck/latestay-jquery
  • 8. Ditching JQuery - Hao Luo - Madison PHP Late Stay Workflow 8 HTTP GET latestayapp.com/purejs HTML (empty ul#applications container) AJAX GET latestayapp.com/applications JSON (parses then inserts in #applications container) (admin clicks on the approve button) AJAX PUT latestayapp.com/applications/20/approve JSON (update HTML) AJAX DOM Events
  • 9. Ditching JQuery - Hao Luo - Madison PHP DOM Querying, Traversal, and Manipulation 9
  • 10. Ditching JQuery - Hao Luo - Madison PHP Some DOM Operations 10 JQuery Vanilla JS $(‘#application-20’); document.querySelector(‘#application-20’); $el.attr(‘data-id’, ‘20’); $el.attr(‘data-id’); el.setAttribute(‘data-id’, ‘20’); el.getAttribute(‘data-id’); yes yes yes 9+ yes yes yes yes yes yes yes 10+$el.addClass(‘approved’); $el.removeClass(‘approved’); $el.toggleClass(‘approved’); el.classList.add(‘approved’); el.classList.remove(‘approved’); el.classList.toggle(‘approved’); $el.data(‘id’, ‘20’); var id = $el.data(‘id’); el.dataset.id = ‘20’; var id = el.dataset.id; yes yes yes 11+ $button.closest(‘.application’); button.closest(‘.application’); 41 35 no no https://dom.spec.whatwg.org/#dom-element-closestselectors https://github.com/eligrey/classList.js/
  • 11. Ditching JQuery - Hao Luo - Madison PHP Polyfills 11 A polyfill is a piece of code that provides the technology that the developer expects the browser to provide natively. Flattening the API landscape if you will. - Remy Sharp var ELEMENT = Element.prototype; ELEMENT.matches = ELEMENT.matches || ELEMENT.msMatchesSelector || ELEMENT.mozMatchesSelector || ELEMENT.webkitMatchesSelector; ELEMENT.closest = ELEMENT.closest || function (selector) { var node = this; while (node) { if (node.matches(selector)) { break; } node = node.parentElement; } return node; }; 41 35 no no yes yes yes 9+ <li class="application" id=“#application-20"> … <div class="action-bar"> <div class=“action"> … <button class="delete"> </div> </div> </li> deleteButton.closest('.application'); HTML Javascript Javascript
  • 12. Ditching JQuery - Hao Luo - Madison PHP DOM Events 12
  • 13. Ditching JQuery - Hao Luo - Madison PHP13 Register Event Callbacks Yes Yes Yes 9+ JQuery $('.delete').on('click', deleteApplication); Vanilla JS getAllElToArr('.delete').forEach(function (el) { el.addEventListener('click', deleteApplication); });
  • 14. Ditching JQuery - Hao Luo - Madison PHP li.application ☺☹ ✖li.application ☺☹ ✖ Direct Events (vs Delegated Events) 14 li.application li.application li.application div#application-container ul#applications li.application JQuery $('.delete').on('click', deleteApplication); Vanilla JS getAllElToArr('.delete').forEach(function (el) { el.addEventListener('click', deleteApplication); }); EventListener #1 EventListener #4 EventListener #3 EventListener #2 EventListener #5 EventListener #6 ✖ ✖ ✖ ✖
  • 15. Ditching JQuery - Hao Luo - Madison PHP li.application ☺☹ ✖ Delegated Events 15 li.application li.application li.application div#application-container ul#applications li.application li.application ☺☹ ✖ JQuery $(‘ul.applications’).on(‘click’, ‘.deleteBtn’, deleteApplication); Vanilla JS No Standard for Event Delegation :(✖ ✖ ✖ ✖ EventListener #1 is the ‘click’ target element the ‘.delete’ button? if so, run deleteApplication is the ‘click’ target element the ‘.approve’ button? if so, run approveApplication https://github.com/ftlabs/ftdomdelegate
  • 16. Ditching JQuery - Hao Luo - Madison PHP AJAX 16
  • 17. Ditching JQuery - Hao Luo - Madison PHP AJAX 17 JQuery $.ajax(); Vanilla JS XMLHttpRequest HTML5 Fetch API yes yes yes yes 41 no no no Fetch API Polyfill: https://github.com/github/fetch yes yes yes 9+
  • 18. Ditching JQuery - Hao Luo - Madison PHP POST - A Closer Look 18 JQuery XMLHttpRequest $.ajax('/applications', { method: 'POST', contentType: 'application/json', processData: false, data: JSON.stringify({ name: 'Joe Bob', reason: 'Too cold outside' }) }) .then(function success(application) { appendApplicationHTML(application); }) .fail(function failed() { console.log('request failed!'); }); xhr = new XMLHttpRequest(); xhr.open('POST', '/applications')); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onload = function() { if (xhr.status === 200) { var applicationInfo = JSON.parse(xhr.responseText); appendApplicationHTML(application); } else if (xhr.status !== 200) { alert('Request failed. '); } }; xhr.send(JSON.stringify({ name: 'Joe Bob', reason: 'Too cold outside' });
  • 19. Ditching JQuery - Hao Luo - Madison PHP POST - A Closer Look 19 JQuery Fetch API $.ajax('/applications', { method: 'POST', contentType: 'application/json', processData: false, data: JSON.stringify({ name: 'Joe Bob', reason: 'Too cold outside' }) }) .then(function success(application) { appendApplicationHTML(application); }) .fail(function failed() { console.log('request failed!'); }); fetch('/users', { method: 'post', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'Joe Bob', reason: 'Too Cold Outside' }) }) .then(function (response) { return response.json(); }) .then(function (application) { appendApplicationHTML(application); }) .catch(function(error) { console.log('request failed', error); });
  • 20. Ditching JQuery - Hao Luo - Madison PHP DeferredValue Eliminates Callback hell Offers More Flexibility and Freedom Promises are awesome 20
  • 21. Ditching JQuery - Hao Luo - Madison PHP Utilities 21
  • 22. Ditching JQuery - Hao Luo - Madison PHP DOM Loaded 22 JQuery Vanilla JS $(function(event) { console.log("DOM fully loaded and parsed"); }); document.addEventListener("DOMContentLoaded", function(event) { console.log("DOM fully loaded and parsed"); }); yes yes yes 9+ Don’t use "load"
  • 23. Ditching JQuery - Hao Luo - Madison PHP HTML Parse 23 JQuery Vanilla JS var el = $.parseHTML(HTMLString); var parser = new DOMParser(); var doc = parser.parseFromString(HTMLString, 'text/html'); var el = doc.body.firstChild; 30 12 7.1 10+ function parseHTML (str) { var tmp = document.implementation.createHTMLDocument(''); tmp.body.innerHTML = str; return tmp.body.firstChild; }; IE9 won’t accept empty param yes yes yes 9+
  • 24. Ditching JQuery - Hao Luo - Madison PHP Date Parse IE9 needs W3C output (which is also ISO 8601 compliant) (http://www.w3.org/TR/NOTE- datetime-970915.html) 24 <?php $objDateTime = new DateTime('NOW'); echo $objDateTime->format('c'); // 1975-12-25T14:15:16-05:00 Yes IE9 echo $objDateTime->format(DateTime::ISO8601); // 1975-12-25T14:15:16-0500 No IE9
  • 25. Ditching JQuery - Hao Luo - Madison PHP A word about JQuery Animate •Use Semantic HTML •Use CSS Transition 25 .application { opacity: 1; max-height: 300px; transition: max-height 0.5s, opacity 0.7s; } .application.removed { max-height: 0; opacity: 0; } CSS
  • 26. Ditching JQuery - Hao Luo - Madison PHP Closing Thoughts 26
  • 27. Ditching JQuery - Hao Luo - Madison PHP27 Non-Technical Reasons • a lot of magic is confusing sometimes • Understanding the basics makes you a better developer $('div'); //creates a jquery instance with the selection inside $('<div>'); //creates a jquery instance with a new element not in document $($aJQueryInstance); //makes a clone of $aJQueryInstance $(function() {}) //registers function to run after DOM is loaded $({foo: 'bar'}); //??? creates a jquery set that has a subset of methods ??? var $appsEl1 = $('#applications'); var $appsEl2 = $('#applications'); $appsEl1 === $appsEl2; //false var appsEl1 = document.querySelector('#applications'); var appsEl2 = document.querySelector('#applications'); appsEl1 === appsEl2; //true
  • 28. Ditching JQuery - Hao Luo - Madison PHP Some Takeaways •Avoid monolithic libraries & frameworks and Use Packages and Polyfills •Out of the JQuery Plugin Ecosystem and into NPM or Bower •Browser and Server 28
  • 29. Ditching JQuery - Hao Luo - Madison PHP When to use JQuery •When you have to support IE8 •When you don’t have CORS •Abstractions sometimes are good! 29 uses requestAnimationFrames for its animationsuses setInterval for its animations
  • 30. Ditching JQuery - Hao Luo - Madison PHP Resources for DOM references http://blog.garstasio.com/you-dont-need-jquery/ http://youmightnotneedjquery.com/ http://html5please.com/ 30
  • 31. Ditching JQuery - Hao Luo - Madison PHP Thank you! @howlowck https://joind.in/16012 31