SlideShare una empresa de Scribd logo
1 de 87
Descargar para leer sin conexión
Nano? Pico? Femto? Atto?



Zepto!
  @thomasfuchs



    (cc) 2011 Thomas Fuchs
“real” computer
Fast and stable network connection
Lots of storage
Fast, multi-core CPUs
Hardware-accelerated graphics
Slow & unstable network connection
Limited storage
Slow CPUs
Hardware acceleration only on iOS
All major JS libs
  where created
before phones had
 web browsers to
write home about.
Don’t use something
  because it’s popular.

Use stuff because it’s the
 right tool for the job.
WebKit
Proprietary features
Adoption of features
  from JavaScript
    frameworks
Proprietary features
   are awesome
CSS Selectors
document.querySelectorAll('div.awesome > p')
full featured
              CSS3 selectors

// select all li elements with both "just" and "testing"
classnames
document.querySelectorAll('li.just.testing')

// how many paragraphs?
document.querySelectorAll('p').length

// select even paragraphs
document.querySelectorAll('p:nth-child(2n+1)')
[].slice.apply(nodelist)

           convert to
        JavaScript array



   document.querySelectorAll
   returns a NodeList, not an array
querySelectorAll


Full-featured CSS selectors
No need for external JavaScript libraries
Fast, native implementation

Returns a NodeList, not an array
JSON
JSON.stringify({
   s: 'a string',
   n: 123,
   d: new Date
})
JSON.parse('{"some":"json","test":123}')
Native JSON

Parsing JSON (convert to JS object)
Serializing JS objects to JSON
Fast, native implementation
No problem with security of “eval” as in
some JavaScript-based
implementations
Array iteration
[1,2,3].forEach(alert);
[1,2,3].forEach(alert);




array with three numbers
[1,2,3].forEach(alert);




   forEach is a native function on
 arrays, taking a function argument
[1,2,3].forEach(alert);




          call with window.alert
                   function
[1,2,3].forEach(alert);
[].slice.apply(nodelist).forEach(
    function(element){
      alert(element.innerHTML);
    }
 );



Iterate through all elements found,
  alerting the element’s contents
Array Iteration
Array Iteration

No more for loops required
Array Iteration

No more for loops required
No more for loops required
Array Iteration

No more for loops required
No more for loops required
No more for loops required
Array Iteration

No more for loops required
No more for loops required
No more for loops required
No more for loops required
Array Iteration

No more for loops required
No more for loops required
No more for loops required
No more for loops required
No more for loops required
Mobile JavaScript
  framework?
Why not use
Prototype, jQuery or
 other frameworks?
Some functionality is not
supported or not meaningful
    on mobile devices.



                              resizing & scrolling
                              orientation
                              fixed positioning
                              fonts
                              SVG
More code causes longer download
     and initialization times.
Most of the downloaded code
      isn’t even used.

(there’s no IE 6 to support on
  mobile phones, lucky us)
A lot of the rest of the code is
duplicating features that are
 directly available as native
      implementations.
Goals for a mobile
JavaScript framework
Reduce code size as much as
possible to keep download and
  initialization times down.
Easy to use API—possibly
emulating jQuery because
developers already know it.
Easy to extend and customize—
again, jQuery has a familiar plugin/
       extension mechanism
Ideally, have a fallback mechanism
  in case it’s run on non-WebKit
          mobile browsers.
It’s not so important
   what’s there, but
   what’s not there.
Meet zepto.js
     http://github.com/madrobby/zepto


Target size: 5K
jQuery-compatible API
Uses mobile WebKit features whenever possible
Easily replaceable with jQuery proper if needed
Doesn’t cover all of jQuery (but lots of it!)
31.33K




               4.83K
              Zepto (master)
 jQuery 1.6
Various special cases
Main use case $(some selector)
this saves ~6k of selector engine code
make sure dom is a JavaScript array
swap out the
      prototype,
  but leave “length”
and other properties
   intact, uses the
     proprietary
 __proto__ property
Z.prototype is pointing to $.fn which holds all
  methods that are used on found elements
Reusing array methods, works because
     we have an array-like object
this is an array-like of resulting nodes
 and a Zepto object at the same time
insertAdjacentElement is IE-
proprietary, but supported by WebKit




  (doesn’t work on Firefox!)
Zepto.js
    http://github.com/madrobby/zepto


CSS Selectors and DOM manipulation
Ajax including x-domain JSONP
Events (including touch events)
Polyfills and bug fixes for older WebKits
Modular (can leave out events, xhr, etc.)
WebKit only! (with focus on mobile)
/
m.checkers.com
One more thing…
scriptaculous
Prototype.js
jQuery
mootools
Micro-Frameworks




                   you/users are the rebels
                   —the ewoks are helping
                   you achieve your goals
Classic frameworks

Do all things and do it ok-ish
Force you into an API
Not modular/not modular enough
25k+ minified & gzipped
Many extensions are now available
in the DOM or JavaScript
Micro-Frameworks
      (are awesome!)
do one thing and do it really well
smaller than 5k, minified & gzipped
use directly or loosely coupled
Small is beautiful
easier to understand code & fork
downloads and runs faster
fewer bugs (less code!)
…and you’ll learn how
JavaScript REALLY works
{{ mustache }} ~ 1.5k
Lawnchair ~ 2.0k
Backbone.js ~ 3.9k
But how do I know
 what’s out there?
microjs.com
Add your own!
github.com/madrobby/
     microjs.com
Questions?
  @thomasfuchs

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013Node.js, for architects - OpenSlava 2013
Node.js, for architects - OpenSlava 2013
 
Introduction to Python Celery
Introduction to Python CeleryIntroduction to Python Celery
Introduction to Python Celery
 
Introduction to node.js aka NodeJS
Introduction to node.js aka NodeJSIntroduction to node.js aka NodeJS
Introduction to node.js aka NodeJS
 
Node js for beginners
Node js for beginnersNode js for beginners
Node js for beginners
 
Nodejs getting started
Nodejs getting startedNodejs getting started
Nodejs getting started
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
JavaScript Web Workers
JavaScript Web WorkersJavaScript Web Workers
JavaScript Web Workers
 
Node, express & sails
Node, express & sailsNode, express & sails
Node, express & sails
 
Web workers
Web workersWeb workers
Web workers
 
Introduction to REST API with Node.js
Introduction to REST API with Node.jsIntroduction to REST API with Node.js
Introduction to REST API with Node.js
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Super combinators
Super combinatorsSuper combinators
Super combinators
 
Test your Javascript! v1.1
Test your Javascript! v1.1Test your Javascript! v1.1
Test your Javascript! v1.1
 
Deploy Node.js application in Heroku using Eclipse
Deploy Node.js application in Heroku using EclipseDeploy Node.js application in Heroku using Eclipse
Deploy Node.js application in Heroku using Eclipse
 
Back to the future: Isomorphic javascript applications
Back to the future:  Isomorphic javascript applicationsBack to the future:  Isomorphic javascript applications
Back to the future: Isomorphic javascript applications
 
Data processing with celery and rabbit mq
Data processing with celery and rabbit mqData processing with celery and rabbit mq
Data processing with celery and rabbit mq
 
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better NetworkingITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
ITT 2014 - Erik Hellmann - Android Programming - Smarter and Better Networking
 
No Va Taig April 7 2010
No Va Taig April 7 2010No Va Taig April 7 2010
No Va Taig April 7 2010
 
The current state of web
The current state of webThe current state of web
The current state of web
 
webworkers
webworkerswebworkers
webworkers
 

Destacado

Destacado (11)

Javascript Framework Acessibiliity Review
Javascript Framework Acessibiliity ReviewJavascript Framework Acessibiliity Review
Javascript Framework Acessibiliity Review
 
Offline Mode - Web Applications Offline
Offline Mode - Web Applications OfflineOffline Mode - Web Applications Offline
Offline Mode - Web Applications Offline
 
ECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
ECMA5 approach to building JavaScript frameworks with Anzor BashkhazECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
ECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
 
Create a landing page
Create a landing pageCreate a landing page
Create a landing page
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
 
Paweł Danielewski, Jak wygenerować 56% konwersji na Landing Page i 193.000 zł...
Paweł Danielewski, Jak wygenerować 56% konwersji na Landing Page i 193.000 zł...Paweł Danielewski, Jak wygenerować 56% konwersji na Landing Page i 193.000 zł...
Paweł Danielewski, Jak wygenerować 56% konwersji na Landing Page i 193.000 zł...
 
Creating responsive landing pages using LeadSquared
Creating responsive landing pages using LeadSquaredCreating responsive landing pages using LeadSquared
Creating responsive landing pages using LeadSquared
 
WebApps e Frameworks Javascript
WebApps e Frameworks JavascriptWebApps e Frameworks Javascript
WebApps e Frameworks Javascript
 
50 Landing Page Best Practices
50 Landing Page Best Practices50 Landing Page Best Practices
50 Landing Page Best Practices
 
Unobtrusive JavaScript with jQuery
Unobtrusive JavaScript with jQueryUnobtrusive JavaScript with jQuery
Unobtrusive JavaScript with jQuery
 
Writing Efficient JavaScript
Writing Efficient JavaScriptWriting Efficient JavaScript
Writing Efficient JavaScript
 

Similar a Zepto and the rise of the JavaScript Micro-Frameworks

Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
gouthamrv
 
Playframework + Twitter Bootstrap
Playframework + Twitter BootstrapPlayframework + Twitter Bootstrap
Playframework + Twitter Bootstrap
Kevingo Tsai
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
Fred Sauer
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
catherinewall
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
dswork
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 

Similar a Zepto and the rise of the JavaScript Micro-Frameworks (20)

GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
 
Griffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java TechnologyGriffon: Re-imaging Desktop Java Technology
Griffon: Re-imaging Desktop Java Technology
 
J Query
J QueryJ Query
J Query
 
Playframework + Twitter Bootstrap
Playframework + Twitter BootstrapPlayframework + Twitter Bootstrap
Playframework + Twitter Bootstrap
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
node.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoonnode.js 실무 - node js in practice by Jesang Yoon
node.js 실무 - node js in practice by Jesang Yoon
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and BackboneJavascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
Javascript Frameworks Comparison - Angular, Knockout, Ember and Backbone
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Javascript Frameworks Comparison
Javascript Frameworks ComparisonJavascript Frameworks Comparison
Javascript Frameworks Comparison
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
Flu3nt highlights
Flu3nt highlightsFlu3nt highlights
Flu3nt highlights
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
JavaScript on the server - Node.js
JavaScript on the server - Node.jsJavaScript on the server - Node.js
JavaScript on the server - Node.js
 
jQuery with javascript training by Technnovation Labs
jQuery with javascript training by Technnovation LabsjQuery with javascript training by Technnovation Labs
jQuery with javascript training by Technnovation Labs
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 

Más de Thomas Fuchs

Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Thomas Fuchs
 

Más de Thomas Fuchs (9)

Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2KZepto.js, a jQuery-compatible mobile JavaScript framework in 2K
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K
 
I Can't Believe It's Not Flash
I Can't Believe It's Not FlashI Can't Believe It's Not Flash
I Can't Believe It's Not Flash
 
Prototype & Scriptaculous
Prototype  & ScriptaculousPrototype  & Scriptaculous
Prototype & Scriptaculous
 
Extreme JavaScript Performance
Extreme JavaScript PerformanceExtreme JavaScript Performance
Extreme JavaScript Performance
 
Textorize
TextorizeTextorize
Textorize
 
Adventures In JavaScript Testing
Adventures In JavaScript TestingAdventures In JavaScript Testing
Adventures In JavaScript Testing
 
Ruby On Rails Introduction
Ruby On Rails IntroductionRuby On Rails Introduction
Ruby On Rails Introduction
 
Twistori Tech
Twistori TechTwistori Tech
Twistori Tech
 
Rich and Snappy Apps (No Scaling Required)
Rich and Snappy Apps (No Scaling Required)Rich and Snappy Apps (No Scaling Required)
Rich and Snappy Apps (No Scaling Required)
 

Último

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
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

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
 
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?
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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...
 
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
 
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...
 
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
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 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
 
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)
 
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
 
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...
 
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
 
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 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 

Zepto and the rise of the JavaScript Micro-Frameworks