开发者

Removing unused jQuery Mobile elements?

I'm using jQuery Mobile beta. It's great fun to work with, but it's still very slow on a 3G connection.

It requires the following files:

http://code.jquery.com/jquery-1.6.1.min.js (89KB)
http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js (65KB)
http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css (41KB)

These are all above the 25KB iPhone cache limit, and even with a cache-manifest, mean that the site is pretty slow to render first time around.

Not unusably slow, but enough to be unpleasant (and yes, I know "slow" is subjective, but so is everything in UI development).

Has anyone figured out a way to cut down the size of these files - either the unused bits of jQuery, or a way to remove parts of the CSS file, depending on which elements are开发者_高级运维 actually used?

Thanks a lot.


there's no way to automate this process. If you want to go and remove what's not being used you have to do it yourself. But your gain will be minimal. You won't reach 25kb in any of them.

Use html5 cache manifest to store the files locally and as you've said only the first load will be slower. No way around it.


I know this is an old question, but here goes anyway: You can use the jquerymobile "download-builder" to create a custom build with only the components you need!


From here:

(...) web pages designed specifically for the iPhone should reduce the size of each component to 25 Kbytes or less for optimal caching behavior.

So, the obvious thing to do here is to "break down" your scripts and styles into multiple files of less than 25KB. You'd have to host them yourself then, obviously.


You can get the whole build setup from github, remove widgets you don't need trom the manifest and build it then.

On linux - just use make

On Windows - you'll have to run the PHP build script

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜