SlideShare a Scribd company logo
1 of 40
How To Manage Large
Applications with jQuery or
whatever
Alex Sexton
@slexaxton
Bay Area jQuery Conference 2010 BAjQCON
WHY?


  Because I’m tired of stuff like this
WHY!?
WHY!?!!11one


 And you’re probably tired of maintaining it.
Wouldn’t this be nice?
Start thinking about our sites as Apps instead of a pile
of scripts.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks, but
  aren’t loaded by the hundreds at the top of your page
  Where you look at your code, and you understand
  what it does.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks, but
  aren’t loaded by the hundreds at the top of your page
  Where you look at your code, and you understand
  what it does.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks,
  but aren’t loaded by the hundreds at the top of
  your page
  Where you look at your code, and you understand
  what it does.
IN A WORLD:
(Read this in the movie-trailer-guy smoky-voice)

  Where changing the dom doesn’t break your app
  Where you can re-use portions of your code (OMG)
  Where your files are separated based on tasks, but
  aren’t loaded by the hundreds at the top of your page
  Where you look at your code, and you understand
  what it does.
Let’s Arbitrarily Pick Four
Things, kk?

 Inheritance Model
 Configurable Mixin Options
 Dom to Object Bridge
 Dependency Management
Inheritance Model
Pick what you like, I really really don’t care which



  Native / Pseudo-Classical (<-- Crock’s word not mine)
  Classical
  Prototypal
                                             Inheritance
Native / PseudoClassical
Native / PseudoClassical
 Weird, I know

 Blame Java (Brendan Eich is blameless (ok maybe not but still...))

 JavaScript (ECMA) is a Functional language with
 Imperative/Classical syntax (Specifically like if Java took advantage of Scheme)

 Important to grok, and easy once you get the hang of
 it, even if you never use it / hate it.
Classical Inheritance
Classical Inheritance
 If you’ve ever taken a programming course, you already
 know this (AKA a good starting point)

 Has some overhead since it isn’t native

 Not really the JavaScriptiest way to do it, but who
 cares?

 There’s a bunch-o-options: Simple Inheritance,
 Mootools Classes, LowPro, Base2, and MOAR!
Prototypal Inheritance
Prototypal Inheritance
Prototypal Inheritance


 Papa Crockford likes it and I kinda like him
 Fits into the language the best
 jQuery.extend means easy Multiple Inheritance!
 Not always complex enough, forealz
Quote from Crocky

“It doesn't matter what an
object's lineage is, what
matters is the quality of its
contents”
KK, I get Inheritance, sup next?
KK, I get Inheritance, sup next?
     Yeah right, but ok, we’ll move on.
Configurable Mixin Options
or a fancy name for Jamming
Two Objects together
Always do this.
Trust me.
It works better than Find in Files -> “#BADA55”
Let’s get a little more
advanced.


 The DOM to Object Bridge (yes, this is a list)
DOM <-> Object

If you start with a DOM Element, easily get back to its
related Object in your App (good for user interaction)
Describe your site in Objects, but still have an easy link
to it’s displayed DOM element (good for automatic
things)
Step 1: Create Your Object
Step 2: Create A Bridge
Step 3: Marvel at how much
more modular you just got.




More importantly, everything is configurable from a
                   single place.
AAAND if you somehow end up with the DOM
element, and you need to execute a plugin function:
OK, so now I’m modular, but
I have 18 files loading, what
would Steve Souders think?!

 Dependency Management FTMFW
Dependency Management

Javascript doesn’t do this by default like many
languages (include, require, etc)
Can be done serverside or clientside these days
Smart people already did all the hard work (Pretty much just James
Burke, but that must mean he’s really good at it though...)
Dependency Management
RequireJS

It takes some configuration. Get over it.
It’s actually faster than just including script tags, since
it’s asynchronous by default. yay steve!
Takes a few instructions and only loads what’s
necessary when it’s necessary.
RequireJS




 Wrap a module with its dependencies and
RequireJS will ensure those dependencies are
                   loaded.
RequireJS

This is great during development, but loading
everything individually during production might cause
some slowdown.
You can run a server-side build based on your
RequireJS dependency tree and get exactly what you
need combined and minified.
LabJS
LabJS is not for dependency management in the
strictest terms, but it is a lighter weight alternative to
RequireJS that helps you load everything in the highest
performing manner possible.




 Here, you tell LabJS what modules need to finish
 executing before being executing the next ones.
In the end

 You have clearly defined modules.
 You have easy bridges between your dom and your
 objects, but they are loosely coupled.
 You load your app as a single call, and the
 dependencies are figured out.
 Your page’s performance increases as well as your
 sanity level
Fin.
    Alex Sexton                                         BFFS4EVAR
    AlexSexton[at]gmail
    @slexaxton
    http://alexsexton.com/
    http://yayquery.com/
    http://alexsexton.com/inheritance/demo

Special Thanks to: Mike & Pierson Taylor, Paul Irish, Rebecca Murphey, Adam J Sontag,
John Resig, James Burke, Kyle Simpson, Crock, Eich and everyone who watches
yayQuery!

More Related Content

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony 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
 
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
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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?Antenna Manufacturer Coco
 
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
 
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
 
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
 
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
 
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.pdfUK Journal
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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?
 
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...
 
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
 
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
 
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
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony 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
 
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
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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?
 
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
 
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
 
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
 
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
 
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
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

How To Manage Large jQuery Apps

  • 1. How To Manage Large Applications with jQuery or whatever Alex Sexton @slexaxton Bay Area jQuery Conference 2010 BAjQCON
  • 2. WHY? Because I’m tired of stuff like this
  • 4. WHY!?!!11one And you’re probably tired of maintaining it.
  • 5. Wouldn’t this be nice? Start thinking about our sites as Apps instead of a pile of scripts.
  • 6. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 7. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 8. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 9. IN A WORLD: (Read this in the movie-trailer-guy smoky-voice) Where changing the dom doesn’t break your app Where you can re-use portions of your code (OMG) Where your files are separated based on tasks, but aren’t loaded by the hundreds at the top of your page Where you look at your code, and you understand what it does.
  • 10. Let’s Arbitrarily Pick Four Things, kk? Inheritance Model Configurable Mixin Options Dom to Object Bridge Dependency Management
  • 11. Inheritance Model Pick what you like, I really really don’t care which Native / Pseudo-Classical (<-- Crock’s word not mine) Classical Prototypal Inheritance
  • 13. Native / PseudoClassical Weird, I know Blame Java (Brendan Eich is blameless (ok maybe not but still...)) JavaScript (ECMA) is a Functional language with Imperative/Classical syntax (Specifically like if Java took advantage of Scheme) Important to grok, and easy once you get the hang of it, even if you never use it / hate it.
  • 15. Classical Inheritance If you’ve ever taken a programming course, you already know this (AKA a good starting point) Has some overhead since it isn’t native Not really the JavaScriptiest way to do it, but who cares? There’s a bunch-o-options: Simple Inheritance, Mootools Classes, LowPro, Base2, and MOAR!
  • 18. Prototypal Inheritance Papa Crockford likes it and I kinda like him Fits into the language the best jQuery.extend means easy Multiple Inheritance! Not always complex enough, forealz
  • 19. Quote from Crocky “It doesn't matter what an object's lineage is, what matters is the quality of its contents”
  • 20. KK, I get Inheritance, sup next?
  • 21. KK, I get Inheritance, sup next? Yeah right, but ok, we’ll move on.
  • 22. Configurable Mixin Options or a fancy name for Jamming Two Objects together
  • 24. Trust me. It works better than Find in Files -> “#BADA55”
  • 25.
  • 26. Let’s get a little more advanced. The DOM to Object Bridge (yes, this is a list)
  • 27. DOM <-> Object If you start with a DOM Element, easily get back to its related Object in your App (good for user interaction) Describe your site in Objects, but still have an easy link to it’s displayed DOM element (good for automatic things)
  • 28. Step 1: Create Your Object
  • 29. Step 2: Create A Bridge
  • 30. Step 3: Marvel at how much more modular you just got. More importantly, everything is configurable from a single place.
  • 31. AAAND if you somehow end up with the DOM element, and you need to execute a plugin function:
  • 32. OK, so now I’m modular, but I have 18 files loading, what would Steve Souders think?! Dependency Management FTMFW
  • 33. Dependency Management Javascript doesn’t do this by default like many languages (include, require, etc) Can be done serverside or clientside these days Smart people already did all the hard work (Pretty much just James Burke, but that must mean he’s really good at it though...)
  • 35. RequireJS It takes some configuration. Get over it. It’s actually faster than just including script tags, since it’s asynchronous by default. yay steve! Takes a few instructions and only loads what’s necessary when it’s necessary.
  • 36. RequireJS Wrap a module with its dependencies and RequireJS will ensure those dependencies are loaded.
  • 37. RequireJS This is great during development, but loading everything individually during production might cause some slowdown. You can run a server-side build based on your RequireJS dependency tree and get exactly what you need combined and minified.
  • 38. LabJS LabJS is not for dependency management in the strictest terms, but it is a lighter weight alternative to RequireJS that helps you load everything in the highest performing manner possible. Here, you tell LabJS what modules need to finish executing before being executing the next ones.
  • 39. In the end You have clearly defined modules. You have easy bridges between your dom and your objects, but they are loosely coupled. You load your app as a single call, and the dependencies are figured out. Your page’s performance increases as well as your sanity level
  • 40. Fin. Alex Sexton BFFS4EVAR AlexSexton[at]gmail @slexaxton http://alexsexton.com/ http://yayquery.com/ http://alexsexton.com/inheritance/demo Special Thanks to: Mike & Pierson Taylor, Paul Irish, Rebecca Murphey, Adam J Sontag, John Resig, James Burke, Kyle Simpson, Crock, Eich and everyone who watches yayQuery!

Editor's Notes