Closed Bug 1566426 Opened 6 years ago Closed 5 years ago

The CSS on the Beta site uses base64 strings instead of image URLs

Categories

(developer.mozilla.org Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: peterbe, Assigned: peterbe)

References

Details

(Keywords: in-triage, Whiteboard: [points=2])

Attachments

(3 files)

For example, on https://beta.developer.mozilla.org/en-US/docs/Learn we have;

On https://developer.mozilla.org/en-US/docs/Learn we have;

It's great that 3 requests become just 2 because you don't need any CSS related to CKeditor etc. But why is the new sum total 210KB (69.5KB) vs. 138KB (29.5KB). That's 2.3x larger amount of bytes that need to be transferred. (Browsers are fast to parse CSS so the (gzipped) network I/O is more important)

Besides, the HTML document is much larger on the beta site due to all the inline <style> blocks that emotion yields in SSR.
The size difference is:

▶ ls -lh Learn*.html*
-rw-r--r--  1 peterbe  wheel   154K Jul 16 09:06 Learn.beta.html
-rw-r--r--  1 peterbe  wheel    36K Jul 16 09:06 Learn.beta.html.gz
-rw-r--r--  1 peterbe  wheel   109K Jul 16 09:06 Learn.original.html
-rw-r--r--  1 peterbe  wheel    28K Jul 16 09:06 Learn.original.html.gz

In other words, the Beta site is 8KB larger to download.

The beta site HTML uses 35 <style> blocks whose content (uncompressed) is 11KB (2.2KB). So, in total, you're downloading 69.5 + 2.2 KB of CSS on the beta site. (As opposed to 29.5 + 0 KB on the original)

Attached patch bug1566426.diffSplinter Review

If you download the Beta CSS and the original CSS (combined into 1 file) and then pretty print them both equally. Then this diff is what you get.

Assignee: nobody → peterbe

(In reply to Peter Bengtsson [:peterbe] from comment #2)

Created attachment 9078402 [details] [diff] [review]
bug1566426.diff

If you download the Beta CSS and the original CSS (combined into 1 file) and then pretty print them both equally. Then this diff is what you get.

This makes it easier to see: https://gist.github.com/peterbe/45dd5e0b2782fef71ebdbf512a72c3cc

And now I think I get it! base64 images!

Actually, here's the difference of the selectors being used: https://gist.github.com/peterbe/2b2967f5591b08902b4af85db1b9d71e
Basically, it means there's a bunch of BCD related things. E.g.

.bc-head-icon-opera { ... }

is ONLY defined in the Beta site's CSS.

But it also means that the Beta site everything the old site had plus some more.

Blocks: 1561020

By the way, now that we've established that the list of CSS selectors is pretty much the same on the wiki and beta site. If you compare its total CSS selectors compared to the selectors of the minimal CSS (aka. critical CSS) you get this:

https://gist.github.com/peterbe/a0f6d6167b461607de146cdf6dcd3e57

So if you want to make the CSS for the Beta site considerably smaller, manually, consider eye'ing through this list and start scutinizing. E.g. do we really need .wiki-promo-sauce-labs* ??

Summary: Why is the CSS bigger on the beta site than the wiki? → The CSS on the Beta site uses base64 strings instead of image URLs
See Also: → 1566456

Hmm. The total of all data URI strings, for a page like https://beta.developer.mozilla.org/en-US/, is only 53 KB. It's not a sneeze but it definitely is better to use image URLs.

Keywords: in-triage
Whiteboard: [points=2]

Hmm. There are some data URIs we're not easily going to get out of.
https://github.com/mozilla/kuma/blob/601ffa3987a808381d2636689e4b7fb951d7231c/kuma/static/styles/includes/_svg_data_uri_icons.scss
All of these ought to replaced with paths to .svg files and checked into git.

(In reply to Peter Bengtsson [:peterbe] from comment #5)

By the way, now that we've established that the list of CSS selectors is pretty much the same on the wiki and beta site. If you compare its total CSS selectors compared to the selectors of the minimal CSS (aka. critical CSS) you get this:

https://gist.github.com/peterbe/a0f6d6167b461607de146cdf6dcd3e57

So if you want to make the CSS for the Beta site considerably smaller, manually, consider eye'ing through this list and start scutinizing. E.g. do we really need .wiki-promo-sauce-labs* ??

I have logged a tracker[https://bugzilla.mozilla.org/show_bug.cgi?id=1566695] and am starting down the road off finally improving this situation.

(In reply to Peter Bengtsson [:peterbe] from comment #7)

Hmm. There are some data URIs we're not easily going to get out of.
https://github.com/mozilla/kuma/blob/601ffa3987a808381d2636689e4b7fb951d7231c/kuma/static/styles/includes/_svg_data_uri_icons.scss
All of these ought to replaced with paths to .svg files and checked into git.

I will take this on as part of https://bugzilla.mozilla.org/show_bug.cgi?id=1566695

Perhaps we need to file a bug and link it to the above?

MDN Web Docs' bug reporting has now moved to GitHub. From now on, please file content bugs at https://github.com/mdn/sprints/issues/ and platform bugs at https://github.com/mdn/kuma/issues/.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: