SlideShare una empresa de Scribd logo
1 de 10
Patterns andbehaviors
 Optimizations for markup and JavaScript
           on top of patterns.
Content

•   Simple pattern
•   Pattern with logic
•   Pattern with behavior
•   Advantages / Disadvantages




29.06.2012      Tobias Krogh | XING AG | Patters and behaviors   2
Tobias Krogh

•   Frontend Engineer (role of an architect)
•   27 years old
•   XING AG for two years and a quarter
•   jQuery is my favorite library :-)
•   NO twitter account to be followed
•   xing.to/bias
•   stackoverflow.com/users/1342159

29.06.2012       Tobias Krogh | XING AG | Patters and behaviors   3
HTML
                      (simple pattern)
HTML
<divclass="my-pattern-class">
<h4>Wow, I am a headline</h4>
<a href="/form">showtheform</a>
</div>

CSS
.my-pattern-class {
padding: 10px;
}




29.06.2012             Tobias Krogh | XING AG | Patters and behaviors   4
HTML / JS
                   (pattern with logic)
HTML
<divid="foobar" class="my-pattern-class">
<h4>Wow, I am a headline</h4>
<a href="/form">showtheform</a>
</div>
<script>
 // assuming an existingfunction "showLightbox"
 $("#foobara").click(showLightbox);
</script>




29.06.2012              Tobias Krogh | XING AG | Patters and behaviors   5
HTML / JS
               (pattern with behavior)
HTML
<divclass="my-pattern-class">
<h4>Wow, I am a headline</h4>
<a data-module="lightbox"href="/form">showtheform</a>
</div>

JS File
Behaviors.add({
 '[data-module="lightbox"]:click': showLightbox
});
// setbehaviors on DOM ready
$(Behaviors.update);

29.06.2012              Tobias Krogh | XING AG | Patters and behaviors   6
Advantages
             Whatspeaksforusingbehaviors?
•   Save blocking inline script
•   Define / transportthecodeonlyonce
•   JavaScript filesarecached
•   Maintainabilityisimproved
•   Update easilypossible




29.06.2012          Tobias Krogh | XING AG | Patters and behaviors   7
Disadvantages
             Whatspeaksagainstbehaviors?
• Additional markup on elements
• Main disadvantage:




29.06.2012          Tobias Krogh | XING AG | Patters and behaviors   8
Disadvantage: Availability
                   The problem
Bigger JS logicmeansmoretransportevenif not needed:
Behaviors.add({
 "[data-module="lightbox"]:click": function() {
    // e.g. 100 lines and more…
 }
});

• Nofittingmarkupmeans NO need




29.06.2012             Tobias Krogh | XING AG | Patters and behaviors   9
Conclusion

•   Use JS behaviors
•   Most practicalforspreadsimilarscripts
•   Design and interaction will besimilar
•   Document to makeotherdevelopers happy :-)

• Keepfilesize in mind (use AMD) ;-)



29.06.2012      Tobias Krogh | XING AG | Patters and behaviors   10

Más contenido relacionado

Destacado (7)

Dewey
DeweyDewey
Dewey
 
Thesis Presentation
Thesis PresentationThesis Presentation
Thesis Presentation
 
Information Literacy Week 10: Evaluation
Information Literacy Week 10: EvaluationInformation Literacy Week 10: Evaluation
Information Literacy Week 10: Evaluation
 
ACTUALIZACIÓN DEL PLAN DE GESTIÓN INTEGRAL DE RESIDUOS SÓLIDOS DEL MUNICIPIO ...
ACTUALIZACIÓN DEL PLAN DE GESTIÓN INTEGRAL DE RESIDUOS SÓLIDOS DEL MUNICIPIO ...ACTUALIZACIÓN DEL PLAN DE GESTIÓN INTEGRAL DE RESIDUOS SÓLIDOS DEL MUNICIPIO ...
ACTUALIZACIÓN DEL PLAN DE GESTIÓN INTEGRAL DE RESIDUOS SÓLIDOS DEL MUNICIPIO ...
 
42 - IDNOG03 - LT - Akhmad Zaimi - Ansible Ease your config job
42 - IDNOG03  - LT - Akhmad Zaimi - Ansible Ease your config job42 - IDNOG03  - LT - Akhmad Zaimi - Ansible Ease your config job
42 - IDNOG03 - LT - Akhmad Zaimi - Ansible Ease your config job
 
Sckipio G.fast Presentation at TNO Ultrafast Broadband 2015
Sckipio G.fast Presentation at TNO Ultrafast Broadband 2015Sckipio G.fast Presentation at TNO Ultrafast Broadband 2015
Sckipio G.fast Presentation at TNO Ultrafast Broadband 2015
 
HOME COLLECTIONS
HOME COLLECTIONSHOME COLLECTIONS
HOME COLLECTIONS
 

Similar a Pattern behaviors

Html5で変わるいろんなこと
Html5で変わるいろんなことHtml5で変わるいろんなこと
Html5で変わるいろんなこと
Masakazu Muraoka
 

Similar a Pattern behaviors (20)

20150211 seo in drupal presentation
20150211 seo in drupal presentation20150211 seo in drupal presentation
20150211 seo in drupal presentation
 
Lab#2 overview of html
Lab#2 overview of htmlLab#2 overview of html
Lab#2 overview of html
 
[PSU Web 2011] HTML5 Design
[PSU Web 2011] HTML5 Design[PSU Web 2011] HTML5 Design
[PSU Web 2011] HTML5 Design
 
Html,CSS & UI/UX design
Html,CSS & UI/UX designHtml,CSS & UI/UX design
Html,CSS & UI/UX design
 
Html5で変わるいろんなこと
Html5で変わるいろんなことHtml5で変わるいろんなこと
Html5で変わるいろんなこと
 
HTML Semantic Tags
HTML Semantic TagsHTML Semantic Tags
HTML Semantic Tags
 
HTML5 Essential Training
HTML5 Essential TrainingHTML5 Essential Training
HTML5 Essential Training
 
[edUi] HTML5 Workshop
[edUi] HTML5 Workshop[edUi] HTML5 Workshop
[edUi] HTML5 Workshop
 
Unic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projectsUnic - frontend development-in-complex-projects
Unic - frontend development-in-complex-projects
 
Writing an extensible web testing framework ready for the cloud slide share
Writing an extensible web testing framework ready for the cloud   slide shareWriting an extensible web testing framework ready for the cloud   slide share
Writing an extensible web testing framework ready for the cloud slide share
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Take Your Markup to Eleven
Take Your Markup to ElevenTake Your Markup to Eleven
Take Your Markup to Eleven
 
Link your Way to Successful Content Management with MadCap Flare
Link your Way to Successful Content Management with MadCap FlareLink your Way to Successful Content Management with MadCap Flare
Link your Way to Successful Content Management with MadCap Flare
 
Html week8 2019 2020 for g10 by eng.osama ghandour
Html week8 2019 2020 for g10 by eng.osama ghandourHtml week8 2019 2020 for g10 by eng.osama ghandour
Html week8 2019 2020 for g10 by eng.osama ghandour
 
SharePoint & jQuery Guide - SPSTC 5/18/2013
SharePoint & jQuery Guide - SPSTC 5/18/2013 SharePoint & jQuery Guide - SPSTC 5/18/2013
SharePoint & jQuery Guide - SPSTC 5/18/2013
 
How to Not Let Team Authoring Drive You Crazy - MadWorld 2013, Scott DeLoach,...
How to Not Let Team Authoring Drive You Crazy - MadWorld 2013, Scott DeLoach,...How to Not Let Team Authoring Drive You Crazy - MadWorld 2013, Scott DeLoach,...
How to Not Let Team Authoring Drive You Crazy - MadWorld 2013, Scott DeLoach,...
 
HTML5ではないサイトを HTML5へ - Change HTML5 from Not HTML5.
HTML5ではないサイトを HTML5へ - Change HTML5 from Not HTML5.HTML5ではないサイトを HTML5へ - Change HTML5 from Not HTML5.
HTML5ではないサイトを HTML5へ - Change HTML5 from Not HTML5.
 
[heweb11] HTML5 Makeover
[heweb11] HTML5 Makeover[heweb11] HTML5 Makeover
[heweb11] HTML5 Makeover
 
Introduction to Web Components & Polymer Workshop - U of I WebCon
Introduction to Web Components & Polymer Workshop - U of I WebConIntroduction to Web Components & Polymer Workshop - U of I WebCon
Introduction to Web Components & Polymer Workshop - U of I WebCon
 
[O'Reilly] HTML5 Design
[O'Reilly] HTML5 Design[O'Reilly] HTML5 Design
[O'Reilly] HTML5 Design
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
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?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - 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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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...
 
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
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Pattern behaviors

  • 1. Patterns andbehaviors Optimizations for markup and JavaScript on top of patterns.
  • 2. Content • Simple pattern • Pattern with logic • Pattern with behavior • Advantages / Disadvantages 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 2
  • 3. Tobias Krogh • Frontend Engineer (role of an architect) • 27 years old • XING AG for two years and a quarter • jQuery is my favorite library :-) • NO twitter account to be followed • xing.to/bias • stackoverflow.com/users/1342159 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 3
  • 4. HTML (simple pattern) HTML <divclass="my-pattern-class"> <h4>Wow, I am a headline</h4> <a href="/form">showtheform</a> </div> CSS .my-pattern-class { padding: 10px; } 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 4
  • 5. HTML / JS (pattern with logic) HTML <divid="foobar" class="my-pattern-class"> <h4>Wow, I am a headline</h4> <a href="/form">showtheform</a> </div> <script> // assuming an existingfunction "showLightbox" $("#foobara").click(showLightbox); </script> 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 5
  • 6. HTML / JS (pattern with behavior) HTML <divclass="my-pattern-class"> <h4>Wow, I am a headline</h4> <a data-module="lightbox"href="/form">showtheform</a> </div> JS File Behaviors.add({ '[data-module="lightbox"]:click': showLightbox }); // setbehaviors on DOM ready $(Behaviors.update); 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 6
  • 7. Advantages Whatspeaksforusingbehaviors? • Save blocking inline script • Define / transportthecodeonlyonce • JavaScript filesarecached • Maintainabilityisimproved • Update easilypossible 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 7
  • 8. Disadvantages Whatspeaksagainstbehaviors? • Additional markup on elements • Main disadvantage: 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 8
  • 9. Disadvantage: Availability The problem Bigger JS logicmeansmoretransportevenif not needed: Behaviors.add({ "[data-module="lightbox"]:click": function() { // e.g. 100 lines and more… } }); • Nofittingmarkupmeans NO need 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 9
  • 10. Conclusion • Use JS behaviors • Most practicalforspreadsimilarscripts • Design and interaction will besimilar • Document to makeotherdevelopers happy :-) • Keepfilesize in mind (use AMD) ;-) 29.06.2012 Tobias Krogh | XING AG | Patters and behaviors 10