akamai / boomerang

End user oriented web performance testing and beaconing
http://akamai.github.io/boomerang/
Other
1.86k stars 292 forks source link

Reduce the file size of snippets #329

Closed liufei closed 2 years ago

liufei commented 2 years ago

Before:

build/snippets/continuity-snippet.min.js: Size of 298 bytes (0.29 kilobyte)
build/snippets/loader-snippet-after-onload.min.js: Size of 2,445 bytes (2.39 kilobyte)
build/snippets/loader-snippet.min.js: Size of 2,133 bytes (2.08 kilobyte)

After:

build/snippets/continuity-snippet.min.js: Size of 255 bytes (0.25 kilobyte)
build/snippets/loader-snippet-after-onload.min.js: Size of 2,309 bytes (2.25 kilobyte)
build/snippets/loader-snippet.min.js: Size of 1,997 bytes (1.95 kilobyte)
bluesmoon commented 2 years ago

Does this have any difference after gzipping?

liufei commented 2 years ago

Well, it looks like the file is bigger. :sweat:

Before:

gzip-size build/snippets/continuity-snippet.min.js
166 B

gzip-size build/snippets/loader-snippet-after-onload.min.js
973 B

gzip-size build/snippets/loader-snippet.min.js
888 B

After:

gzip-size build/snippets/continuity-snippet.min.js
166 B

gzip-size build/snippets/loader-snippet-after-onload.min.js
981 B

gzip-size build/snippets/loader-snippet.min.js
890 B
bluesmoon commented 2 years ago

In general, don't worry about optimising files that are under 1492 bytes. A single TCP packet is 1500 bytes, and you'll lose 8 bytes if the client has to go through a NAT firewall, this means anything under 1492 bytes will always take one TCP packet whether it is 1 byte or 1492 bytes.

liufei commented 2 years ago

You're right, it really isn't necessary. Thank you very much!