Assets & configuration

How to reduce the APK size of an HTML app

We built the same HTML app seven times, slimming one thing at a time, and measured every APK. Images were worth more than everything else combined. Here's the order that pays off.

To shrink an HTML app's APK, fix the images first: resize them to the size a phone actually shows and convert them to WebP. Then move or shrink any video, switch fonts to WOFF2, and ship minified JavaScript. We measured each step in real builds of the same app. Images alone took the APK from 17.48 MB to 10.83 MB. All five steps together brought it to 7.35 MB, and the web files' own share fell from 10.79 MB to 0.67 MB.

The order matters because Android doesn't treat all files the same. Text files are compressed inside the APK, while photos and video go in exactly as they are. That's why minifying JavaScript, the step most guides start with, saved the least.

How we tested

We started from our free Recipe Box sample app, which adds just 47 KB to an APK, and loaded it with what real projects tend to ship:

That made a 12.9 MB project. We then fixed one thing at a time, keeping each change, and built a real APK after every step with the same HTML-to-APK runtime this site uses. Every build started from clean (see the warning further down for why that matters). The runtime itself, with no web content, is 6.68 MB, shown in grey below.

Bar chart of APK size after each step: 17.48 MB as built, 10.83 MB after converting images to WebP, 10.17 MB after WOFF2 fonts, 9.68 MB after minified JavaScript, 7.90 MB after re-encoding the video to 720p and 7.35 MB after streaming the video instead
Each bar is a real APK build. The grey part is the app runtime, the same in every build. The teal part is your web files.

Why images matter most: what Android compresses

An APK is a ZIP file. When it's built, text files are compressed, but media files are stored as they are, because they're already compressed. We opened the "as built" APK and checked every file:

File typeIn the projectIn the APKStored as
JPEG photos (6)3.82 MB3.82 MBAs is (100%)
PNG images (2)3.19 MB3.19 MBAs is (100%)
MP4 video2.28 MB2.28 MBAs is (100%)
TTF fonts (4)1.49 MB0.71 MBCompressed (47%)
JavaScript (4)1.10 MB0.32 MBCompressed (29%)
Source map0.73 MB0.21 MBCompressed (29%)
HTML + CSS10 KB5 KBCompressed

So 1 MB of JavaScript costs about 0.3 MB in the APK, but 1 MB of photos costs a full 1 MB. Start with the files that go in untouched.

Step 1 — Resize and convert images to WebP

A phone screen is about 1080 pixels wide, and an image in a card or a column is usually far less. A 2400 px photo carries detail nobody will ever see. Resize every photo to at most 1280 px on its longer side and save it as WebP at quality 80:

cwebp -q 80 -resize 1280 0 photo.jpg -o photo.webp

On our test photo that went from 599 KB to 69 KB. The 3.2 MB PNG hero became 63 KB. Across all seven images, this one step removed 6.65 MB from the APK, more than every other step put together. Then update the file names in your HTML or data files.

The same test photo as a 599 KB JPEG and as a 71 KB WebP, shown side by side at phone size with a zoomed crop of each; the two look the same
At the size a phone shows it, the WebP is indistinguishable from the original, even in a zoomed crop.

Keep PNG only for images that need sharp edges and transparency, such as logos, icons and screenshots of text. Photos should never be PNG.

WebP ConverterShrink app images without visible loss Open the tool

Step 2 — Fonts: WOFF2, only the weights you use

Font files are compressed in the APK, but TTF still compresses poorly. Two changes help. First, include only the weights your CSS actually uses. Most sites declare four and use two. Second, convert them to WOFF2 with only the characters you need:

pyftsubset Georgia.ttf --unicodes="U+0020-007E,U+00A0-00FF" --flavor=woff2 --output-file=georgia.woff2

That turned a 380 KB TTF into a 33 KB WOFF2 covering English and Western European text. Going from four TTF weights to two subset WOFF2 files saved 0.66 MB. The cheapest font of all is none: a system font stack (system-ui, sans-serif) costs 0 KB and looks native on every phone.

Step 3 — Ship production JavaScript, delete source maps

Swap development builds of libraries for their production (minified) versions, and delete every .map file before you zip the project. Source maps help you debug on a desktop, and they do nothing inside an app. This step saved 0.49 MB: real, but small, because the APK was already compressing that text to 29% of its size. Delete anything else the app never loads at the same time, such as design files, READMEs, test folders and stray node_modules.

Step 4 — Shrink the video, or don't bundle it

Video goes into the APK untouched, so every megabyte counts. A 1080p intro is overkill on a phone screen. Re-encoding it to 720p cut it from 2.28 MB to about 0.5 MB and the APK by 1.78 MB:

ffmpeg -i intro.mp4 -vf scale=1280:-2 -c:v libx264 -crf 30 -preset slow -c:a aac -b:a 64k -movflags +faststart intro-720p.mp4

If the video isn't essential offline, load it from the web instead. Removing it from the bundle saved another 0.56 MB. Our bundled vs live URL guide explains what a bundled page can and can't load from the internet.

Step 5 — Measure the right way

Check what's actually in your APK before and after each change. An APK is a ZIP, so you can list it:

unzip -l app.apk | sort -k1 -n -r | head -20

One trap caught us during this test. If you build the APK yourself in Android Studio, debug builds are packaged incrementally: deleted files leave unused space behind, so the APK can stay the same size after you remove megabytes. Our first round of builds showed almost no change from steps 2 to 4 for exactly this reason. Always do a clean build (Build → Clean Project, or delete app/build) before comparing sizes. Converter services build from scratch every time, so they don't have this problem.

APK Size CalculatorEstimate your app's size before you build Open the tool

Common mistakes

Questions people ask

What makes an HTML app's APK big?

Mostly images, video and audio. Android stores those in the APK as they are, while HTML, CSS, JavaScript and fonts are compressed. In our test, photos and video made up 9.3 MB of a 10.8 MB project, and text files only about 1.2 MB once compressed.

Is WebP supported in Android WebView?

Yes. Android's WebView displays WebP images, so you can use them in the img tags and CSS of a converted app exactly as you would on a website.

Does minifying JavaScript reduce APK size much?

Less than you'd expect. The APK already compresses JavaScript, so in our test switching to minified builds and deleting the source map saved 0.49 MB, against 6.65 MB for converting images.

Why didn't my APK get smaller after I deleted files?

Android Studio packages debug APKs incrementally, which can leave unused space where deleted files were. Do a clean build before comparing sizes.

How small can an HTML app's APK be?

The app runtime is the floor. In our tests it was 6.68 MB on its own, and the Recipe Box sample app added only 47 KB on top.

Read next

Ready to turn your site into an app?

Upload an HTML file or a ZIP, set your icon and name, and download a signed Android app. No Android Studio, no command line.

Open the builder