Why My 8-Second Text GIF Weighed 308 KB (and What Actually Shrinks It)
This is the default animation on Typing Text GIF. Two words of black text, three short orange phrases, a blinking cursor: It is 627 by 123 pixels. It uses three colors. It runs for 7.9 seconds. It weighs 308 KB. For
This is the default animation on Typing Text GIF. Two words of black text, three short orange phrases, a blinking cursor:
It is 627 by 123 pixels. It uses three colors. It runs for 7.9 seconds.
It weighs 308 KB.
For scale, the entire text of The Great Gatsby is around 270 KB. My GIF of the word "websites" outweighs Fitzgerald. That felt wrong enough that I took the file apart.
A GIF is a flipbook, and the flipbook is dumb
The first surprise: this animation is 79 frames, and the number has nothing to do with how fast it types.
A typing animation needs one frame per visible state. Type a letter, that's a frame. Backspace a letter, that's a frame. Cursor blinks off, frame. Blinks on, frame. The three phrases have 35 characters between them, so that's 35 frames going forward, 35 going back, and nine blinks.
I checked this by changing the typing speed from 8 characters a second to 24. Duration went from 10.8 seconds to 6.4. File size: 308 KB, 308 KB. Not one byte of difference. Speed is free. Each frame just carries a different "show me for this long" number.
So the cost is roughly frames × bytes per frame, and here each frame costs about 3.9 KB. Every frame stores the whole picture again, all 77,121 pixels, including the words "We build" that haven't moved since frame one.
That's the flipbook. Now, what moves the number?
What each setting is worth
I re-exported the same sentence with one change at a time:
Reading it top to bottom:
Blink off: −9%. The blinks during each pause are extra frames. Turning them off merges each pause into one long frame. Cheap, but the cursor is half the charm, so I'd leave it.
Smaller font: −34%. Going from 48px to 32px shrinks the canvas from 627×123 to 440×103. Fewer pixels per frame, every frame. If the GIF is going in an email signature at 300 pixels wide anyway, exporting at 48px is paying for pixels nobody will see.
Clear instead of backspace: −40%. This is the big one, and it's obvious once you see the frame count. Backspacing spends a frame per deleted letter. Clearing the phrase in one go drops 79 frames to 47. You lose the backspace animation, which some people love. But it's 122 KB of love.
Both together: 123 KB. Tighten the padding too and you're at 107 KB, about a third of where we started, and it's still the same sentence in the same font.
The part that annoyed me
Those are settings. They trade looks for bytes. What bothered me was the 3.9 KB per frame for a picture that barely changes. Type one letter and maybe 400 pixels are different. Why store 77,000?
So I ran an experiment. Same 79 frames, same pixels on screen, written to the file four different ways:
One shared palette: 278 KB. A GIF frame can carry its own color table. The encoder I use writes one for every frame, and they're all nearly identical. Sharing a single table saves about 30 KB. Nice, not dramatic.
Only the changed pixels: 67 KB. This is the real trick, and it's almost embarrassingly simple. For every frame after the first, compare each pixel to the previous frame. If it's the same, don't write its color. Write "transparent" instead:
const out = new Uint8Array(index.length);
for (let k = 0; k < index.length; k++) {
out[k] = index[k] === previous[k] ? TRANSPARENT : index[k];
}
The viewer keeps the previous frame on screen and paints the new one on top, so "transparent" means "leave whatever was there". A frame becomes 76,000 identical "skip" values and a few hundred real ones. GIF's compression is built for long runs of the same value, so those 76,000 pixels collapse to almost nothing.
Same animation, pixel for pixel. 4.6 times smaller.
I haven't shipped this yet, for a boring reason: it steals the transparent slot. If you export with a see-through background, "transparent" already means something, and it can't mean two things. It needs a second code path, and I'd rather ship one that's right than two that are nearly right.
And then there's the last bar
Animated PNG, same frames: 32 KB. A tenth of the GIF, and with smooth edges on any background, because PNG stores real transparency.
It isn't cleverness on my part. The PNG encoder does the "only store what changed" trick by default and uses a better compressor. The newer format is simply better at this than the one from 1987.
The catch is where it plays. Browsers, yes. iMessage, yes. A lot of email clients and chat apps, no, or only the first frame. So the honest advice is unglamorous: use APNG where you control the page, GIF where you don't, and when it has to be GIF, pick "clear" over "backspace" and don't export bigger than you'll display.
What's the most absurd file size you've seen for something that looked tiny?
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.

