How strongly jQMobile depends on jQuery?
I have built an app using jQuery mobile. Apart of some compatibility issues across different Android devices I have experienced extremely poor performance on Android system. Because even clean template from jquerymobile.com works slow on my galaxy tab I've decided that maybe remov开发者_运维技巧ing unnecessary parts of jQuery will speed it up a bit. But has anyone already tried it ? Is it even possible ?
It is impossible to run jQuery Mobile without jQuery itself. (that's for the people who might come here and not know that already)
You can try to shrink the size of JQ and JQM. Sadly, I don't think there is a lot to remove from jQuery. I'll give it anoder thought and edit ;)
But you sure can "clean up" jQuery Mobile as it consists of widgets. Get JQM from github, read about "compilation" and you'll know what to do.
I am planning to do the exact thing, so I'm quite sure it can be done.
If you don't use selectboxes you can just remove the widget from the manifest file and after making
its CSS and code should not get into the build.
So you can easily shrink JQM down upto (my guess) about half the size if you don't use any form elements, collapsibles listviews etc. and the basics should still work.
[edit]
Possible jQuery shrinking will be hard, but you can try removing:
- the new deferred ajax handling (if it's not too deeply integrated)
- animation
- $.css (possibly, I'm not sure if JQM uses that or not, but it's a big chunk of code and you can deal without it)
The best way to do the tidying is to replace the body of the function you think you don't need with a alert('damnit!')
to see if you really didn't need it ;)
To be sure it remains working and stable you should only replace functions that are bound to names. Try not to replace or remove any closures or functions that return functions.
And do it AFTER YOUR code is TESTED to always work correctly. Repeat tests after messing up the J*
I think the true issue is not about Javascript. It is caused by HTML and CSS added by JQuery Mobile. JQuery Mobile will add div wrapper and CSS to original HTML. The resulted HTML bloated with additional divs and CSS slows down performance.
you can try a already rendered webpage without jQuery and jQMobile javascript on iphone. It is still slow and flashing when you scroll fast. Another framework iUI http://code.google.com/p/iui/ runs better on long list, because the html code and CSS are simpler. Or, you can compare it with simplest long list without CSS:
<ul>
<li> 1 </li>
<li> 2 </li>
...
<li> 500 </li>
</ul>
I've been testing a lot with jQuery and jQuery Mobile lately and I haven't noticed any issues on my ipad2. I suspect a lot of this is going to come down to how much you want to support outdated hardware. Mobile space is moving fast, and I predict it'll be like the late 90s when cross-browser support (not to even mention the limited options for supporting multiple screen resolutions back then) required a mess of scripts and redirects based on things like user agent detection.
精彩评论