SlideShare una empresa de 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;

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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 a 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 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

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
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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 interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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 MenDelhi Call girls
 
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
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - 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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
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 textsMaria Levchenko
 

Último (20)

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)
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
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
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - 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...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 

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.