SlideShare uma empresa Scribd logo
1 de 29
High performancewebsites & Best practices Session 1: JavaScript hints and introduction to JQuery
User interface Structure  Presentation Behavior : HTML : CSS : JavaScript
Structure : HTML What’s the different parts of the content and how they are related. Presentation : CSS How the content should be displayed and formatted visually. Behavior : JavaScript How the content react based on the user interaction.
Why this separation? Portability Maintainability Better performance Accessibility ….. >> ility # 1
JavaScript JavaScript make pages interactive. For example: you can show and hide sections of the page, add client side validations, drag and drop elements on the page, and much more.
How to get JavaScript in my page? Inline script BAD ,[object Object],Ok ,[object Object],Perfect
How does JavaScript interact with the page? Through Dom Dom is a tree of objects <html>    <body> 	<p id=“first”></p> 	<p id=“second”> 		<strong>text</strong> 	</p> 	<p id=“third”></p>    </body> </html> Window     document 	|-p #first 	|-p #second 	|   strong 	p #third
Dom terminology HTMLJavaScript Element			Node Attribute			Property
How can I grab stuff? Get Methods getElementById 		Gets one element. JavaScript: 	document.getElementById(‘about’); CSS: 	#about {} HTML: 	<div id=“about”></div>
getElementsByTagName 		Gets many elements. JavaScript: 	document.getElementById(‘about’).getElementsByTagName(‘p’); CSS: 	#about p{} HTML: 	<div id=“about”> 			<p id=“first”></p> 			<p id=“second”></p> 	</div
By class? By CSS selector?
How else I can grab stuff? p.parent p.childNode p.firstChild p.lastChild s.previousSibiling s.nextSibiling
I have some elements, How do I make them do stuff? Event 	Occur whenever actions happen on the page. Most common: ,[object Object]
mouseover
mouseout
load
keypress
focus,[object Object]
Hint: Object detection Don’t test for browsers, test for capabilities. Don’t use this: If(navigator.appName == “IE”) el.doSomething(); Use this: If(el.SomeIeMethod){ el.SomeIeMethod(); }
Now I have event listeners attached.What can I do with them? ANYTHING
You can change the style
What is “this”? Reference to the object owns the function. So you can attach the same event listener to multiple elements.
But now we’re mixing presentation and behavior! Oh No You can use classes
What if my elements already have some classes? <p class=“special”></p> this.className = ‘inactive’; <p class=“inactive”></p> Whoops! hasClass / addClass / removeClass
How hard is JavaScript to learn? …..
Fast hints: Case sensitivity Optional semi columns 	a=3; 	b=3; 	a=3; b=4; 	return 	true; 	return true; JSLint.com
Main data types Number Strings Boolean values null “undefined” : has not been declared or has not given a value. Variable typing: untyped
Declaring variables: var Without are declared global variables. var a = 1; a = 1;

Mais conteúdo relacionado

Mais procurados

ARTDM 170 Week 3: Rollovers
ARTDM 170 Week 3: RolloversARTDM 170 Week 3: Rollovers
ARTDM 170 Week 3: Rollovers
Gilbert Guerrero
 
Project Feedloop
Project FeedloopProject Feedloop
Project Feedloop
chrisiegers
 

Mais procurados (20)

Presentation on blogs
Presentation on blogsPresentation on blogs
Presentation on blogs
 
How to not create an unbreakable Rails monolith
How to not create an unbreakable Rails monolithHow to not create an unbreakable Rails monolith
How to not create an unbreakable Rails monolith
 
ARTDM 170 Week 3: Rollovers
ARTDM 170 Week 3: RolloversARTDM 170 Week 3: Rollovers
ARTDM 170 Week 3: Rollovers
 
See how i make 300$ daily
See how i make  300$ daily See how i make  300$ daily
See how i make 300$ daily
 
Project Feedloop
Project FeedloopProject Feedloop
Project Feedloop
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
Rapid Testing, Rapid Development
Rapid Testing, Rapid DevelopmentRapid Testing, Rapid Development
Rapid Testing, Rapid Development
 
Responsive Navigation Patterns - Respond 2014
Responsive Navigation Patterns - Respond 2014Responsive Navigation Patterns - Respond 2014
Responsive Navigation Patterns - Respond 2014
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Christmas Trees Made with HTML CSS and JS
Christmas Trees Made with HTML CSS and JSChristmas Trees Made with HTML CSS and JS
Christmas Trees Made with HTML CSS and JS
 
Teacher website
Teacher websiteTeacher website
Teacher website
 
Eliminate Dregol.com
Eliminate Dregol.com Eliminate Dregol.com
Eliminate Dregol.com
 
Eliminate Dregol.com
Eliminate Dregol.com Eliminate Dregol.com
Eliminate Dregol.com
 
Js events
Js eventsJs events
Js events
 
The webmasters struggle - JD19NL
The webmasters struggle - JD19NLThe webmasters struggle - JD19NL
The webmasters struggle - JD19NL
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
Javascript event handler
Javascript event handlerJavascript event handler
Javascript event handler
 
Deepika Mittal , BCA Third Year
Deepika Mittal , BCA Third YearDeepika Mittal , BCA Third Year
Deepika Mittal , BCA Third Year
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
Scott Porad - Web 2.0 Expo SF 2011
Scott Porad - Web 2.0 Expo SF 2011Scott Porad - Web 2.0 Expo SF 2011
Scott Porad - Web 2.0 Expo SF 2011
 

Destaque (8)

Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5Migrating from PHP 4 to PHP 5
Migrating from PHP 4 to PHP 5
 
Scala Validation with Functional Programming
Scala Validation with Functional ProgrammingScala Validation with Functional Programming
Scala Validation with Functional Programming
 
Lecture7 pattern
Lecture7 patternLecture7 pattern
Lecture7 pattern
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
 
Web engineering lecture 4
Web engineering lecture 4Web engineering lecture 4
Web engineering lecture 4
 
Principles for knowledge engineering on the Web
Principles for knowledge engineering on the WebPrinciples for knowledge engineering on the Web
Principles for knowledge engineering on the Web
 
Brief introduction on human resource management
Brief introduction on human resource managementBrief introduction on human resource management
Brief introduction on human resource management
 
Marketing digital, nouvellestendances
Marketing digital, nouvellestendancesMarketing digital, nouvellestendances
Marketing digital, nouvellestendances
 

Semelhante a High performance websites session1

javscript
javscriptjavscript
javscript
rcc1964
 
SES Toronto 2008; Joe Dolson
SES Toronto 2008; Joe DolsonSES Toronto 2008; Joe Dolson
SES Toronto 2008; Joe Dolson
Joseph Dolson
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JS
ikhwanhayat
 

Semelhante a High performance websites session1 (20)

JavaScript and DOM Pattern Implementation
JavaScript and DOM Pattern ImplementationJavaScript and DOM Pattern Implementation
JavaScript and DOM Pattern Implementation
 
Accessible Websites With Lotus Notes/Domino, presented at the BLUG day event,...
Accessible Websites With Lotus Notes/Domino, presented at the BLUG day event,...Accessible Websites With Lotus Notes/Domino, presented at the BLUG day event,...
Accessible Websites With Lotus Notes/Domino, presented at the BLUG day event,...
 
javscript
javscriptjavscript
javscript
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom Manipulation
 
Building Web Hack Interfaces
Building Web Hack InterfacesBuilding Web Hack Interfaces
Building Web Hack Interfaces
 
Mdst 3559-02-10-jquery
Mdst 3559-02-10-jqueryMdst 3559-02-10-jquery
Mdst 3559-02-10-jquery
 
Javascript 2009
Javascript 2009Javascript 2009
Javascript 2009
 
Angular Directives from Scratch
Angular Directives from ScratchAngular Directives from Scratch
Angular Directives from Scratch
 
SES Toronto 2008; Joe Dolson
SES Toronto 2008; Joe DolsonSES Toronto 2008; Joe Dolson
SES Toronto 2008; Joe Dolson
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Unobtrusive JavaScript
Unobtrusive JavaScriptUnobtrusive JavaScript
Unobtrusive JavaScript
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
jQuery Mobile
jQuery MobilejQuery Mobile
jQuery Mobile
 
jQuery
jQueryjQuery
jQuery
 
Developing for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformDeveloping for LinkedIn's Application Platform
Developing for LinkedIn's Application Platform
 
JavaScript and Accessibility
JavaScript and AccessibilityJavaScript and Accessibility
JavaScript and Accessibility
 
Web performance essentials - Goodies
Web performance essentials - GoodiesWeb performance essentials - Goodies
Web performance essentials - Goodies
 
J query intro_29thsep_alok
J query intro_29thsep_alokJ query intro_29thsep_alok
J query intro_29thsep_alok
 
Scripting The Dom
Scripting The DomScripting The Dom
Scripting The Dom
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JS
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

High performance websites session1

  • 1. High performancewebsites & Best practices Session 1: JavaScript hints and introduction to JQuery
  • 2. User interface Structure Presentation Behavior : HTML : CSS : JavaScript
  • 3. Structure : HTML What’s the different parts of the content and how they are related. Presentation : CSS How the content should be displayed and formatted visually. Behavior : JavaScript How the content react based on the user interaction.
  • 4. Why this separation? Portability Maintainability Better performance Accessibility ….. >> ility # 1
  • 5. JavaScript JavaScript make pages interactive. For example: you can show and hide sections of the page, add client side validations, drag and drop elements on the page, and much more.
  • 6.
  • 7. How does JavaScript interact with the page? Through Dom Dom is a tree of objects <html> <body> <p id=“first”></p> <p id=“second”> <strong>text</strong> </p> <p id=“third”></p> </body> </html> Window document |-p #first |-p #second | strong p #third
  • 8. Dom terminology HTMLJavaScript Element Node Attribute Property
  • 9. How can I grab stuff? Get Methods getElementById Gets one element. JavaScript: document.getElementById(‘about’); CSS: #about {} HTML: <div id=“about”></div>
  • 10. getElementsByTagName Gets many elements. JavaScript: document.getElementById(‘about’).getElementsByTagName(‘p’); CSS: #about p{} HTML: <div id=“about”> <p id=“first”></p> <p id=“second”></p> </div
  • 11. By class? By CSS selector?
  • 12. How else I can grab stuff? p.parent p.childNode p.firstChild p.lastChild s.previousSibiling s.nextSibiling
  • 13.
  • 16. load
  • 18.
  • 19. Hint: Object detection Don’t test for browsers, test for capabilities. Don’t use this: If(navigator.appName == “IE”) el.doSomething(); Use this: If(el.SomeIeMethod){ el.SomeIeMethod(); }
  • 20. Now I have event listeners attached.What can I do with them? ANYTHING
  • 21. You can change the style
  • 22. What is “this”? Reference to the object owns the function. So you can attach the same event listener to multiple elements.
  • 23. But now we’re mixing presentation and behavior! Oh No You can use classes
  • 24.
  • 25. What if my elements already have some classes? <p class=“special”></p> this.className = ‘inactive’; <p class=“inactive”></p> Whoops! hasClass / addClass / removeClass
  • 26. How hard is JavaScript to learn? …..
  • 27. Fast hints: Case sensitivity Optional semi columns a=3; b=3; a=3; b=4; return true; return true; JSLint.com
  • 28. Main data types Number Strings Boolean values null “undefined” : has not been declared or has not given a value. Variable typing: untyped
  • 29. Declaring variables: var Without are declared global variables. var a = 1; a = 1;
  • 31. What does JQuery do for me? And why to use it? Write less do more Cross browser Simplifies HTML document traversing Simplifies event handling Simplifies animating Simplifies Ajax interactions
  • 32. How to install JQuery? http://jquery.com/ Visual Studio Documentation.