DEV Community

Cover image for Why your website should be under 14kb in size

Why your website should be under 14kb in size

Nathaniel on August 25, 2022

Having a smaller website makes it load faster — that's not surprising. What is surprising is that a 14kB page can load much faster than a 15kB pag...
Collapse
 
ricky11 profile image
Rishi U

Streaming data like videos are sent not over TCP but UDP, UDP is fast because it does not require a three way handshake ACK/SYN/ACK/ACK/FIN.... you dont mind dropped frames in your videos which is why videos over UDP dont need ACK .

Collapse
 
tuxio profile image
Tuxio

That's not correct. When you buffer your videos, they are also sent via TCP and not UDP.
For livestreams that would be correct. But implementations are different on any website..

Collapse
 
nicolus profile image
Nicolas Bailly

you dont mind dropped frames in your videos.

Seriously ? We went to the trouble of making TVs that display 23.976 fps (not 25, not 24, 23.976) so that there wouldn't be any judder when playing a 24p videos, so yeah, I would mind a lot if Netflix started dropping frames when there's some packet loss on the connection.

Collapse
 
basel_arafat_e7bf68b223ee profile image
Basel Arafat

what about dropped frames !

Collapse
 
1link profile image
1Link.Fun

Hi, thanks for the post, it is interesting.

And I have a question, I checked this page and found 2 size number in developer tools

Image description

The first one is 2.6MB is called Size.
The 136.83KB is called "Transferred size of all requests"

Which kind of size should smaller than 14KB to make page load more faster?

Collapse
 
shadowfaxrodeo profile image
Nathaniel

Hi, thanks, the transferred size is the one — meaning the size of the site while it's compressed.

Collapse
 
1link profile image
1Link.Fun

Thanks, glad to know~

Collapse
 
codewithrabeeh profile image
Rabeeh Ebrahim

Where did you get these details?

Collapse
 
1link profile image
1Link.Fun

browser developer tool

Collapse
 
focus97 profile image
Michael Lee

Fantastic article! Never got that detailed into how with respect to packet size and how to optimize for it. The Dice site indeed loaded incredibly fast.

Small pedantic note: the speed of light is 299792458 in a vacuum. The actual signal would move slower from Earth to a satellite since it has to pass through air, so the latency would in fact be a tad longer.

Collapse
 
shadowfaxrodeo profile image
Nathaniel

haha, yes of course, I think you could also take into account how far from the equator you are!

Collapse
 
aileenr profile image
Aileen Rae

Wow, thanks for this! This is closer to the metal than I typically think for web development so I really appreciate how you've written this.

The explanation, the end users that are affected, and the further reading... I really learned a lot, so thank you.

Collapse
 
unthrottled profile image
Alex Simons • Edited

Neat! Didn't think I'd be loading up wireshark ( wireshark.org/) this morning.

It appears that the average packet size my server sends to my computer is 1494 bytes. Here's a small snippet of the traffic I saw from opening unthrottled.io

Image description

I doubt that I have much influence of the TCP transmission (I use AWS Cloudfront), but do you know if there are various factors that affect max packet size? Such as TLS? (this conversation was in TLSv1.2). I know when I saw the initial Client Hello, it asked for ALPN Next Protocol: http/1.1 , so I'll assume this might be a http/1.1 conversation. 🤷 (if that helps)

Collapse
 
shadowfaxrodeo profile image
Nathaniel

I’m not sure, I know the maximum of 1500 bytes is a limitation of Ethernet - and that doesn’t change no matter what protocol you’re using. but that leaves you 6 missing bytes!

Collapse
 
okeken profile image
okeken

This is awesome! thanks for sharing.

Collapse
 
matiashiltunen profile image
MatiasHiltunen

Interesting article! Does http3 quick protocol which is built on top of UDP have any similar quirks?

Collapse
 
shadowfaxrodeo profile image
Nathaniel

Hello, thanks! Yes apparently it does use the same 14kB window. I'm not entirely up to date on how HTTP/3, but my understanding is it similar but more efficient.

I've updated the article with a small paragraph about it, but you can read more about it here: QUIC Loss Detection and Congestion Control.

Collapse
 
habibmanjotha profile image
Habib Manjotha

Thank you for this great article. I'll try to use this rule in my next project.

Collapse
 
midka profile image
Midka

Wow, never though in depth why website size matters 👏

Collapse
 
kissu profile image
Konstantin BIFERT

Interesting post. 👌🏻
I will continue to use Astro and try to keep my JS tidy as much as possible.

Collapse
 
ravavyr profile image
Ravavyr

14kb is a cool concept, a nice idea and definitely fun when you can actually test things on the network at the scale of having to think about how long light takes to travel down the line.

Sadly, this isn't something day-to-day devs can be bothered with.
Content/Marketing teams don't care about this kinda performance, they want their fancy images, animations and tracking scripts so they can boost conversions.

In reality, keeping a site loading in under 1-2 seconds is a far more attainable goal, and sometimes even that is tricky when non-techy people are making the decisions.

Still, the 14kb thing is a neat challenge

Collapse
 
rickdelpo1 profile image
Rick Delpo

I am wondering if u can also write a piece about time to first byte vs first contentfull paint and why load time is different from page speed, not sure I fully get this part. Does loading page scripts impact speed?

Collapse
 
1coma21 profile image
1coma21

Try do to this with ReactJS

Collapse
 
westtrade profile image
Gennadiy Popov

Use SolidJS )

Collapse
 
abhay07 profile image
Abhay Srivastav

This is good. You should probably make a video for it.