
Zepto.js, a jQuery-compatible mobile JavaScript framework in 2K (presentation) - joshuacc
http://mir.aculo.us/2010/10/28/zepto-js-a-jquery-compatible-mobile-javascript-framework-in-2k-presentation/
======
NathanKP
My question is if zepto.js is only 2k then why is jQuery 26k? What features
are left out of Zepto? What are the drawbacks? Or is it just that jQuery isn't
written as efficiently as it should be?

~~~
jeresig
There are a massive number number of features left out - not to mention
critical functionality.

Just taking a quick peek, for example if we look at .show()/.hide():
[http://github.com/madrobby/zepto/blob/master/src/zepto.js#L5...](http://github.com/madrobby/zepto/blob/master/src/zepto.js#L51)
[http://github.com/jquery/jquery/blob/master/src/effects.js#L...](http://github.com/jquery/jquery/blob/master/src/effects.js#L17)

There is a major case where Zepto's technique just straight-out breaks: If you
are showing or hiding anything that isn't a block element. This includes
inline elements, table rows, or inline-block elements.

There doesn't appear to actually be anyway to unbind an event once you've
attached it. Nor any way to detach all handlers of a specific type.

There is not a single bug fix for querySelectorAll - this includes the fact
that querying from rooted nodes is completely broken for most cases.

I can keep going but yeah - there's a world of difference between Zepto and
jQuery.

If you're only targeting bleeding-edge WebKit mobile browsers then yeah, Zepto
might be fine. However in the jQuery project we take a far more pragmatic view
of web development: There are more browsers than just WebKit and the market is
much more complex. You can read more about it here:
<http://jquerymobile.com/strategy/>

~~~
tvandervossen
John, Zepto is _exactly_ intended for targeting bleeding-edge WebKit mobile
browsers. Doesn't the README clearly state that?

~~~
jeresig
Yep - and it's probably fine if you're only building apps for iOS devices -
possibly Android as well. Beyond that you're getting into very shaky
territory. What about Opera (the most popular mobile browser)? What about
Blackberry (the second most popular mobile browser)? What about Symbian (the
most popular mobile platform - which uses antiquated versions of WebKit)?

[http://gs.statcounter.com/#mobile_browser-ww-
monthly-200909-...](http://gs.statcounter.com/#mobile_browser-ww-
monthly-200909-201009)

It frustrates me to no end that the only JavaScript tools being developed in
this day and age, for mobile platforms, exclusively target the latest WebKit:
Sencha Touch, jQTouch, Zepto, etc - they all exclusively focus on the latest
WebKits and it's completely baffling. No web developer in their right mind
would drop support for IE - no one would hire them - and yet they seem to be
fine taking that approach on mobile.

Even if these tools are only being built to be used within a "safe"
environment like PhoneGap - web developers don't understand that distinction.
If the only tools for mobile web developers target WebKit platforms then web
developers will only ever target WebKit platforms. As has been shown in the
past competition is absolutely critical to the health and longevity of the
browser - when one platform dominates and doesn't receive competition the
platform will stagnate.

Not only is targeting multiple platforms pragmatic, you get more users
visiting your sites thus making you more money, but you also help the health
of the mobile web as a whole: Pushing more browsers to compete better and
provide an improved experience to all users.

~~~
tvandervossen
First of all, my company just released a private beta for a large "desktop
class" web application where our client flat-out told us to ignore Internet
Explorer, to not use any Flash (audio playback is a big part of what it does),
and to concentrate our efforts on creating the best possible user experience
on Chrome, Safari, and Firefox. So much for "no one would hire them".

Right now it makes a lot of sense to only target WebKit browsers simply
because it's the only decent rendering engine that's available on decent
mobile phones. Zepto could easily support a mobile version of Firefox or IE
once Firefox catches up in terms of performance and size and IE catches up in
terms of support for HTML5, CSS3 and other emerging web standards.

Finally, stating that "web developers don't understand that distinction"
sounds slightly derogatory, don't you think?

~~~
jeresig
At best developing exclusively for bleeding-edge platforms is a niche-market.
Is there enough interest now to hire a few developers to build HTML 5/CSS
3/etc.-only experiences? Absolutely. Is this a tenable position for anything
more than a minor fraction of the web development market? No.

Companies like making money (naturally). iOS provides a clear path for them:
They build an app, it goes on the app store, out to millions of people, and
the money comes in. That is undisputed - you can absolutely make a nice living
targeting exclusively iOS devices (by extension, WebKit-only platforms).

However this is conflating the problem space of "building mobile web
applications" with "building mobile apps that use web tech". Buiding web-tech
mobile apps is, functionality-wise, a sub-set of building mobile web
applications. Any functionality that you would need to build a mobile web app
you would also need to build a mobile app (albeit you can skim far more off
the file size and functionality by targeting just apps - as Zepto has done).

jQuery is targeted at supporting "building web applications" and "building
mobile web applications" - the two harder problems in the space. When you
compare Zepto (designed to make it easy to build mobile apps targeted at a
single platform) to jQuery (designed to make it easy to build mobile web
applications targeted at many platforms) the difference is night and day.

This is the disingenuous part of this discussion: Zepto is, apparently,
exclusively positioning itself against jQuery - even though they are
completely dissimilar. However to the lay user that distinction is completely
muddled when the API of one is directly compared to the other - when, in fact,
they are nothing alike.

A better comparison would be comparing Zepto to XUI: <http://xuijs.com/> XUI
also targets the best-of-breed mobile platforms and makes it easy to build
mobile apps.

~~~
davebalmer
Agree with a better comparison being XUI, but adding "jQuery" to the
description gets more attention.

I have to say though John that your view of what makes a great app framework
doesn't necessarily matter to everyone. I think your philosophy is executed
quite well in jQuery Mobile, but that doesn't make your approach the best one
for all cases.

Your choice to go for broad support actually weakens the showing of jQuery
Mobile on more shiny devices compared to products which have them in mind to
begin with. Does that make jQuery Mobile then inferior? Hell no! It's great,
does what you set out to do, and does it well.

Thomas' pretty obvious use of the jQuery name to get some attention aside,
there's nothing wrong with zepto's philosophy. It differs from yours, but it
will undoubtedly have an appeal to some people or for certain projects, just
probably not the same projects where someone would find jQuery Mobile
appealing.

------
marcusbooster
Unfortunately, as i recently saw at a demo for Windows Mobile 7, not every
mobile browser uses WebKit. When the guy told me the native browser is based
on IE 7, I just wanted to cry.

------
bentruyman
Now let's get all phone manufacturers to adopt the same version of WebKit.

~~~
madrobby
Zepto.js actually goes in and fixes certain things cross-webkits; but yes, it
would be good if the vendors start to make things more compatible.

