SlideShare a Scribd company logo
1 of 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;

More Related Content

What's hot

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 monolithBruno Almeida
 
ARTDM 170 Week 3: Rollovers
ARTDM 170 Week 3: RolloversARTDM 170 Week 3: Rollovers
ARTDM 170 Week 3: RolloversGilbert Guerrero
 
See how i make 300$ daily
See how i make  300$ daily See how i make  300$ daily
See how i make 300$ daily vision2020166
 
Project Feedloop
Project FeedloopProject Feedloop
Project Feedloopchrisiegers
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScriptShahDhruv21
 
Rapid Testing, Rapid Development
Rapid Testing, Rapid DevelopmentRapid Testing, Rapid Development
Rapid Testing, Rapid Developmentmennovanslooten
 
Responsive Navigation Patterns - Respond 2014
Responsive Navigation Patterns - Respond 2014Responsive Navigation Patterns - Respond 2014
Responsive Navigation Patterns - Respond 2014David Lewis
 
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 JSNiamh Foley
 
Teacher website
Teacher websiteTeacher website
Teacher websiteAaron Gil
 
Eliminate Dregol.com
Eliminate Dregol.com Eliminate Dregol.com
Eliminate Dregol.com jheatondavid
 
Eliminate Dregol.com
Eliminate Dregol.com Eliminate Dregol.com
Eliminate Dregol.com jheatondavid
 
Js events
Js eventsJs events
Js eventsgvbmail
 
The webmasters struggle - JD19NL
The webmasters struggle - JD19NLThe webmasters struggle - JD19NL
The webmasters struggle - JD19NLMike Veeckmans
 
Deepika Mittal , BCA Third Year
Deepika Mittal , BCA Third YearDeepika Mittal , BCA Third Year
Deepika Mittal , BCA Third Yeardezyneecole
 
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 2011Scott Porad
 

What's hot (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
 

Viewers also liked

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 5John Coggeshall
 
Scala Validation with Functional Programming
Scala Validation with Functional ProgrammingScala Validation with Functional Programming
Scala Validation with Functional ProgrammingSukant Hajra
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming692sfrobotics
 
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 WebGuus Schreiber
 
Brief introduction on human resource management
Brief introduction on human resource managementBrief introduction on human resource management
Brief introduction on human resource managementSha Zam
 

Viewers also liked (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
 

Similar to High performance websites session1

JavaScript and DOM Pattern Implementation
JavaScript and DOM Pattern ImplementationJavaScript and DOM Pattern Implementation
JavaScript and DOM Pattern Implementationdavejohnson
 
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,...Martin Leyrer
 
javscript
javscriptjavscript
javscriptrcc1964
 
JavaScript & Dom Manipulation
JavaScript & Dom ManipulationJavaScript & Dom Manipulation
JavaScript & Dom ManipulationMohammed Arif
 
Javascript 2009
Javascript 2009Javascript 2009
Javascript 2009borkweb
 
Angular Directives from Scratch
Angular Directives from ScratchAngular Directives from Scratch
Angular Directives from ScratchChristian Lilley
 
SES Toronto 2008; Joe Dolson
SES Toronto 2008; Joe DolsonSES Toronto 2008; Joe Dolson
SES Toronto 2008; Joe DolsonJoseph Dolson
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
Unobtrusive JavaScript
Unobtrusive JavaScriptUnobtrusive JavaScript
Unobtrusive JavaScriptdaveverwer
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Developing for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformDeveloping for LinkedIn's Application Platform
Developing for LinkedIn's Application PlatformTaylor Singletary
 
JavaScript and Accessibility
JavaScript and AccessibilityJavaScript and Accessibility
JavaScript and AccessibilityJoseph Dolson
 
Web performance essentials - Goodies
Web performance essentials - GoodiesWeb performance essentials - Goodies
Web performance essentials - GoodiesJerry Emmanuel
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JSikhwanhayat
 

Similar to 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
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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 SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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 WorkerThousandEyes
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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...Neo4j
 
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.pptxEarley Information Science
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
[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.pdfhans926745
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
[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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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.