Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Zepto and the rise of the JavaScript Micro-Frameworks

40,607 views

Published on

Here are my slides from JSConf 2011 in Portland, Oregon. I was talking about Zepto, my micro-framework, WebKit-only (works on Firefox too, though) clone of the jQuery API, and why I think that Micro-Frameworks and Micro-Libraries are better suited for the mobile Web than traditional, monolithic libraries, like script.aculo.us, Prototype or jQuery. (A video of the talk is forthcoming and will be announced on my blog, http://mir.aculo.us).

Published in: Technology
  • If you need your papers to be written and if you are not that kind of person who likes to do researches and analyze something - you should definitely contact these guys! They are awesome ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating direct: ♥♥♥ http://bit.ly/369VOVb ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Dating for everyone is here: ❶❶❶ http://bit.ly/369VOVb ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/qURD } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/qURD } ......................................................................................................................... Download doc Ebook here { https://soo.gd/qURD } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Zepto and the rise of the JavaScript Micro-Frameworks

  1. Nano? Pico? Femto? Atto?Zepto! @thomasfuchs (cc) 2011 Thomas Fuchs
  2. “real” computer
  3. Fast and stable network connectionLots of storageFast, multi-core CPUsHardware-accelerated graphics
  4. Slow & unstable network connectionLimited storageSlow CPUsHardware acceleration only on iOS
  5. All major JS libs where createdbefore phones had web browsers towrite home about.
  6. Don’t use something because it’s popular.Use stuff because it’s the right tool for the job.
  7. WebKit
  8. Proprietary features
  9. Adoption of features from JavaScript frameworks
  10. Proprietary features are awesome
  11. CSS Selectors
  12. document.querySelectorAll(div.awesome > p)
  13. full featured CSS3 selectors// select all li elements with both "just" and "testing"classnamesdocument.querySelectorAll(li.just.testing)// how many paragraphs?document.querySelectorAll(p).length// select even paragraphsdocument.querySelectorAll(p:nth-child(2n+1))
  14. [].slice.apply(nodelist) convert to JavaScript array document.querySelectorAll returns a NodeList, not an array
  15. querySelectorAllFull-featured CSS selectorsNo need for external JavaScript librariesFast, native implementationReturns a NodeList, not an array
  16. JSON
  17. JSON.stringify({ s: a string, n: 123, d: new Date})
  18. JSON.parse({"some":"json","test":123})
  19. Native JSONParsing JSON (convert to JS object)Serializing JS objects to JSONFast, native implementationNo problem with security of “eval” as insome JavaScript-basedimplementations
  20. Array iteration
  21. [1,2,3].forEach(alert);
  22. [1,2,3].forEach(alert);array with three numbers
  23. [1,2,3].forEach(alert); forEach is a native function on arrays, taking a function argument
  24. [1,2,3].forEach(alert); call with window.alert function
  25. [1,2,3].forEach(alert);
  26. [].slice.apply(nodelist).forEach( function(element){ alert(element.innerHTML); } );Iterate through all elements found, alerting the element’s contents
  27. Array Iteration
  28. Array IterationNo more for loops required
  29. Array IterationNo more for loops requiredNo more for loops required
  30. Array IterationNo more for loops requiredNo more for loops requiredNo more for loops required
  31. Array IterationNo more for loops requiredNo more for loops requiredNo more for loops requiredNo more for loops required
  32. Array IterationNo more for loops requiredNo more for loops requiredNo more for loops requiredNo more for loops requiredNo more for loops required
  33. Mobile JavaScript framework?
  34. Why not usePrototype, jQuery or other frameworks?
  35. Some functionality is notsupported or not meaningful on mobile devices. resizing & scrolling orientation fixed positioning fonts SVG
  36. More code causes longer download and initialization times.
  37. Most of the downloaded code isn’t even used.(there’s no IE 6 to support on mobile phones, lucky us)
  38. A lot of the rest of the code isduplicating features that are directly available as native implementations.
  39. Goals for a mobileJavaScript framework
  40. Reduce code size as much aspossible to keep download and initialization times down.
  41. Easy to use API—possiblyemulating jQuery becausedevelopers already know it.
  42. Easy to extend and customize—again, jQuery has a familiar plugin/ extension mechanism
  43. Ideally, have a fallback mechanism in case it’s run on non-WebKit mobile browsers.
  44. It’s not so important what’s there, but what’s not there.
  45. Meet zepto.js http://github.com/madrobby/zeptoTarget size: 5KjQuery-compatible APIUses mobile WebKit features whenever possibleEasily replaceable with jQuery proper if neededDoesn’t cover all of jQuery (but lots of it!)
  46. 31.33K 4.83K Zepto (master) jQuery 1.6
  47. Various special cases
  48. Main use case $(some selector)
  49. this saves ~6k of selector engine code
  50. make sure dom is a JavaScript array
  51. swap out the prototype, but leave “length”and other properties intact, uses the proprietary __proto__ property
  52. Z.prototype is pointing to $.fn which holds all methods that are used on found elements
  53. Reusing array methods, works because we have an array-like object
  54. this is an array-like of resulting nodes and a Zepto object at the same time
  55. insertAdjacentElement is IE-proprietary, but supported by WebKit (doesn’t work on Firefox!)
  56. Zepto.js http://github.com/madrobby/zeptoCSS Selectors and DOM manipulationAjax including x-domain JSONPEvents (including touch events)Polyfills and bug fixes for older WebKitsModular (can leave out events, xhr, etc.)WebKit only! (with focus on mobile)
  57. /
  58. m.checkers.com
  59. One more thing…
  60. scriptaculous
  61. Prototype.js
  62. jQuery
  63. mootools
  64. Micro-Frameworks you/users are the rebels —the ewoks are helping you achieve your goals
  65. Classic frameworksDo all things and do it ok-ishForce you into an APINot modular/not modular enough25k+ minified & gzippedMany extensions are now availablein the DOM or JavaScript
  66. Micro-Frameworks (are awesome!)
  67. do one thing and do it really well
  68. smaller than 5k, minified & gzipped
  69. use directly or loosely coupled
  70. Small is beautifuleasier to understand code & forkdownloads and runs fasterfewer bugs (less code!)…and you’ll learn howJavaScript REALLY works
  71. {{ mustache }} ~ 1.5k
  72. Lawnchair ~ 2.0k
  73. Backbone.js ~ 3.9k
  74. But how do I know what’s out there?
  75. microjs.com
  76. Add your own!github.com/madrobby/ microjs.com
  77. Questions? @thomasfuchs

×