2012年11月25日星期日

Who Is Murdering PhoneGap? It's jQuery Mobile

So many people are now arguing the bad performance of PG apps, because of that, many developers stopped entering the army of PG development.
Is PG really so bad?
The answer from me is absolutely NO.
I have to admit that there are so many bad PG apps. Why? Who made them? The most PhoneGap developers. But the developers are innocent of murdering PhoneGap. The real killer is jQuery Mobile.
The bad choice of jQuery Mobile for PhoneGap apps:
1. Not PhoneGap targeted.
jQuery Mobile is not targeting only for PhoneGap apps, instead, it’s developed for mobile WEBSITES. The pages/scripts/resources are organized in a website way, not a native app way. Take pages navigation for an example, a web app navigates to another page by changing the URL, but for desktop/native apps, we new an instance and put it into a wrapper control, the wrapper has full control to the new page, and can receive events of the page, which is quite different from web apps. So, if you are using jQuery Mobile to develop PhoneGap apps, you are probably missing a good application architecture.
2. Too fat & bad performance.
jQuery Mobile does provide very-very many controls/functions, but only a very small part of them are used in apps, which causes much waste of performance. I’d like to take a simple function for example, the scroll. As we know, most mobile browser cores don’t support fixed position, so we have to write custom code to do it and handle the scrolling. jQuery Mobile writes a lot of code for this function, at the same time, a few related touch functions are also provided, but in most cases, the developers only need the scroll. In a word, jQuery Mobile handles too much things for a simple action.
3. Bad documentation.
The jQuery Mobile documentation is not really documentation, but examples. Yeah, they are good examples, but absolutely bad documentation. Not all features are included in the examples, they missed many. This is quite hard for the developers. As some features are hidden from the developers, many developers have to write ugly code.
4. Critical bugs/issues not fixed.
There are so many posts about jQuery mobile scrolling and page flashing. Unfortunately, I don’t see a remarkable answer to their questions. I asked a few developers, they seem to have given it up, and leave the bug/issue as is.
How to make a good PhoneGap app? Here I can share some general ideas:
  • 1. Write your own javascript PhoneGap architecture if you are good at JavaScript. If you are not, you can follow me on codeplex where you can find PhoneGap architecture and demos.
  • 2. Don not write future code. You don’t need to write code that “may be used in future”, instead, write code that is really used.
  • 3. Resolve the critical bugs/issues by yourself. To make a good PhoneGap app, you must first be a JavaScript master, which means you can read others’ code and find the best solution for best of your app.
If you want to develop the best PhoneGap app, you can:
If you are looking for PhoneGap programmers or PhoneGap developers, please feel free to contact us. Free quote is available.

35 条评论:

  1. I concur Leo. I wish people wouldn't use jQuery Mobile when developing PhoneGap apps. It requires you to load a lot of code with jQuery being a dependency of jQuery Mobile and a lot of that code is just not necessary. jQuery is a great framework but there is no need to include support for IE and FF in your mobile app running on a webkit based browser. As well there isn't really a good Android theme for jQM so all of your Android apps look like iOS apps.

    回复删除
  2. I used phonegap with sencha and that was the slowest and worst thing i've ever used as a programmer.

    no comments, phonegap can die by itself because most people require it to be faster, stabler and for gods sake easier to install. dont ask me why but I spent a whole afternoon trying to get it to work, with jqm it was a piece of cake straight out of the website.

    long live jqm.

    回复删除
    回复
    1. I don't think PhoneGap will die, instead, I think it's a very good thing. It will be a replace of most native apps, just like web apps replacing desktop on PC.

      删除
  3. I hope Phonegap will find its success. It has a good idea behind, all it needs it's a better webkit only js framework.

    回复删除
  4. Hi,
    I am using jQM and I am not super happy but it does a really good job of looking and have alot of nice features .. and a nice Theme Builder.

    I would love to get a better framework , but for now I have chosen to live with it.

    Just my 2 cents

    回复删除
  5. Good work, i appreciate your efforts, Thanks for your content.


    iphone apps development

    回复删除
  6. Interesting stuff Leo. Phonegap and it's associated SDKs can be a real pain. What about Phonegap, pure JavaScript instead of the JQM bloat and PhoneGap build to avoid the SDK headache?

    回复删除
  7. Thanks Simon. I have been working with jquery mobile and phonegap recently. Many of the projects are from old existing projects, and the clients want us to make improvements. During which I suffer much from jquery mobile, fortunately, our team made some improvements.

    The biggest problem that jquery mobile brings to us is that the app works in a web-way. Not like a native app.

    回复删除
  8. Hey Leo

    Why don't your team come up with thinned and optimized version of JQuery mobile for Mobile-Web apps? (i mean, not just specified to PhoneGap)

    I think that is much wider and positive approach

    I know you would have considered it, can you share why that ma y not be a better approach, I am sure you will get lot of community support on it

    ~Raj

    回复删除
  9. @Mean Dean: you might consider including Icenium in the build services you talk about in your presentation. I find it very intuitive and easy to use.

    回复删除
  10. You might consider including Icenium in the build services you talk about in your presentation. I find it very intuitive and easy to use.

    回复删除
  11. Any of you looked into Enyo (the former WebOS JS framework) as an alternative to jQM/Sencha?

    http://enyojs.com/

    回复删除
  12. This comment has been removed by the author.

    回复删除
  13. I've been a native iOS app developer for some time now, but the next project I'm working on is pretty straightforward and Phonegap looks like a good fit.

    Although I haven't yet written a line of code from phonegap, I've been researching and was just about to delve into Phonegap with JQM. Performance seems to be the major concern with JQM, although it's a trade off I think I can live with in this instance.

    I did come across this stack overflow article and wondered if many of you have tried this "lazy loading" aka "deferred" approach to loading JQuery.
    http://stackoverflow.com/questions/10945643/correct-way-of-using-jquery-mobile-phonegap-together

    回复删除
  14. Hi Guys,

    I am developing chat app using phonegap and jquerymobile. i will load jquerymobile from url..(like src="http://"). Is this still kills phonegap's performance?

    回复删除
  15. Devil's advocate here, it's neither phonegap nor JQM that is bad, it is the implementation approach the developer takes using JQM and PG. If you literally write web pages exactly as on your website and put them in PG, then yes they will run like a dog, there "ARE" ways to make JQM work very well on PG, but you need a good founding of how JQM and .js works... which a lot of developers just... don't... have.

    回复删除
    回复
    1. This is so true, yet no one even bats an eye to this comment.

      Makes me think there are only people here who like Phonegap and dislike JQM because they cant get it working.

      geez

      删除
    2. Hello my also anonymous friend, I have posted a more detailed reply on October 28, 2013 at 9:47 PM some posts down, I suspect it will get deleted though. I am absolutely adamant on this point though, if you are using JQM and PG together and are finding it slow, YOU ARE WRITING JQM WRONG!

      The cross platform support boiled into JQM makes writing portable, tweakable apps much easier! And what's more the latest 1.4 version is claiming performance gains throughout the framework.

      The approach you take is all a big toss up. Do you want...
      a) Actual web pages in PG
      b) Cross platform HTML5 that looks like an app in PG
      c) Vanilla js you'll have to rewrite a billion times for each platform
      d) God awful javascript frameworks (that make no sense and are as complex if not more so than just learning the native code), that renders native stuff (stuff like appcelerator or windows studio, or other "platforms" that are trying to push "HTML5" to make native UI)
      e) Native code

      p.s. I'm betting you see elements of this debate appear in mainstream consultancy reports within the next year or two. If you are that consultant, hello, must be good earning a cart load by googling this stuff? Let me save you some time.... developers who are "worth their salt" don't want native and they don't want native that is written using javascript, they want actual REAL HTML5 with UI's that work well and look good, from off the shelf open source frameworks. Everyone else is just messing about for the fun of it.

      删除
  16. Why are you using a different HTML file for each page? In our experience this decreases performance when compared to showing and hiding divs within one HTML page. This method also causes headaches with page transitions. I'd like to try your framework in one of our projects but I'm unsure of this method of page switching.

    回复删除
    回复
    1. It's also worth mentioning you can develop with separate files and have a guild build task to combine certain or all templates later.

      删除
  17. Is this project still alive? Is it called "Cordova" or "Nova"??

    Ambitious and promising, unfortunately maybe a bit too much so - can't get the sample app to run ("missing nova.Carousel.js") - hopes for a simple alternative to jQuery Mobile fading again...

    回复删除
    回复
    1. "Cordova" is the open source apache project but it's still packaged as phonegap by Adobe, there is also a new CLI using node/npm that came out with version 3.0.0 which makes developing these applications a dream.

      删除
  18. I tried to used JQuery Mobile and it was a realy disaster, it's very slow! I would recommend using Cordova, Zepro and JQuery Touch.

    回复删除
    回复
    1. Here is another post that experimented jQM performance. The result is surprising. Check here:
      http://apachecordova.blogspot.com/2013/08/how-jquery-mobile-eats-phonegap-performance.html

      删除
  19. If you are familar with java gwt-phonegap is also a perfect solution, especially for business applications.

    回复删除
  20. I'm not a fan of jqmobile but I completely disagree that phonegap is deserving of the praise you're giving it.

    There is are both phonegap and cordova files included in the platform builds, but they don't specify which you need to include. Including cordova is the only way to get plugins to work, but then you get 'cordova.js included multiple times.' errors. Including phonegap throws "cordova class not found" errors...

    It's really just sad that such an ambitious project still hasn't found the grounding to allow you to create a practical application easily. Sure, the demo apps get up and running without an issue.. but as soon as you make an application that actually does anything, it breaks.. fun.

    Anyway, I hope it gets better because it's a fantastic idea, but right now, it needs way too much work for me to do anything other than bitch about it.

    回复删除
    回复
    1. Hi, I do think PhoneGap is almost perfect. I guess you don't find a good project architecture for your phonegap projects, that's why you think cordova.js is hard to use.

      Our phonegap team have done some projects recently without jQueryMobile, the performance and user experience are really good, and the development is fast. PhoneGap saves much cost for the clients.

      If you want to know how our PhoneGap team organize the project files/architecture, you can find some demos with source code here:
      http://cordova.codeplex.com

      删除
  21. Guys, finally, what's the best option for today? Nova? gwt-phonegap? write everything manually?

    回复删除
  22. As I stated a quiet a few posts up, the reason you are finding it slow is because you don't know how to code performance JQM code. Plain and simple. In fact I'd go as far as to say most javascript developers don't really understand the language or how to code performance javascript.

    The fact of the matter is, writing hybrid apps probably has the same complexity as fully native (if you know what the hell you are doing, which I suspect most don't), HOWEVER, once written it is a MUCH smaller task to port the hybrid apps to other platforms..... THIS is the true reason why I use JQM and PG together, once you get past your own arrogance (and I speak as a person who had this view) that you "know javascript" because you've been a web-monkey for years and you actually truly start to learn how to code it properly and how to optimise loops and selectors and the like, you realise that coding performance JQM gives you a MASSIVE head start in porting apps. I currently support android, ios, windows phone 8 and a web version of an app using VERY similar code.

    Say what you like, but I'm just gonna keep repeating this...

    You "can" write fast JQM+PG apps if you know how to write performance javascript.... however, I will be so bold to reiterate once more.... MOST javascript coders have no clue as to what they're really doing.

    回复删除
  23. All well and good, but most dev's don't want to throw the baby out with the bath water.

    You're writing an entire framework from scratch ignoring the years of effort and expertise put into JQ and JQM (or any other framework for that matter) simply because you couldn't spend the time to make JQM work correctly. I think you would have gained more by investing more time in understanding and contributing too existing frameworks. Nevertheless, I'm not gonna take away from you what you have achieved, Good luck to you sir, Good... luck....

    回复删除
  24. Some people consider phonegap to be a slow tool, but I think it totally depends on the developer and the language. You can seamlessly generate apps for different mobile platforms using one single code base. This tool is quite easy to use. Future lies in the hands of cross platform app development. Businesses do not want to spend much on individual applications when they have better options to choose from.

    回复删除
  25. You comment on JQM having bad documentation to which I agree and tell that you're working on an own JS framework specifically targeted for Cordova. After more than a year of development and, to say in your own words, more than 5 apps based on the Nova framework. The documentation (http://cordova.codeplex.com/documentation) is still barely existing.

    回复删除
    回复
    1. Yes, it is. We now have Chinese version of the doc, but the English one is not completed. As there are very few people out of our company following us, we didn't spent much time on documentation or demos. I hope more people can follow us, though the documentation is not 100% complete, the framework is stable now.

      删除
  26. Phone gap is one of the tool which mostly developers used for make a website software. Using platform every developers make app which is more and more supportable. Great post!

    回复删除