Richard
Richard

Reputation: 32979

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.

Upvotes: 4

Views: 967

Answers (4)

Jamie
Jamie

Reputation: 1937

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!

Upvotes: 1

naugtur
naugtur

Reputation: 16905

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

Upvotes: 0

Ruslan
Ruslan

Reputation: 10147

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.

Upvotes: 0

tiagoboldt
tiagoboldt

Reputation: 2426

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.

Upvotes: 1

Related Questions