Reduce size of HTML export zip

Bug #1518832 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Won't Fix
Low
Unassigned

Bug Description

With Bug 1515826 we're now including all the theme assets for a page, in its HTML export file.

Unfortunately, this bumps the unzipped web archive contents up over 8MB. Which isn't a whole lot in the scheme of things I suppose, but before we did this, it was about 500kB. The main culprit is the raw/static/fonts directory included in the export, which is 8MB on its own. The opensans folder alone is about 6MB.

The typical use-case for these fonts is for people to include them with a rel link to a remote server, like this: <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

We should see if we could make that happen with our export code, in order to reduce the size of the export.

Revision history for this message
Robert Lyon (robertl-9) wrote :

The fonts that are used form this directory are included in the css via the @font-face option.

On the export we could find the places this occurs and then find out exactly which fonts we need to include via <link> tags in the header of the export html.

So for example this code in the raw theme css

@font-face {
    font-family: "Open Sans";
    font-style: italic;
    font-weight: 300;
    src: url("../fonts/opensans/OpenSansLightItalic.eot") format("embedded-opentype"), url("../fonts/opensans/OpenSansLightItalic.woff2") format("woff2"), url("../fonts/opensans/OpenSansLightItalic.woff") format("woff"), url("../fonts/opensans/OpenSansLightItalic.ttf") format("truetype"), url("../fonts/opensans/OpenSansLightItalic.svg#OpenSansLightItalic") format("svg");
}

we would find out the font-family, font-style, and font-weight so we can make a
<link href='https://fonts.googleapis.com/css?family=Open+Sans:i300' rel='stylesheet' type='text/css'>

To fetch the correct font

It would be worth doing a check of what the google api returns so that if google doesn't know about the font we still include the local one in the zip

Revision history for this message
Robert Lyon (robertl-9) wrote :

Now that I've taken a quick look at this there is a problem when we loop thru the css files and find/replace the @font-face info with the info retrieved from google. The multiple queries to google make the export process take longer.

I'm not sure the extra waiting justifies the saving of about 8MB - it may look like a big increase when only exporting a few pages
but 8MB is still small potatoes, it would take less than 1sec for many to download.

Swapping the @font-face out to be fetched straight from google could also cause issues if the person want to view the html without connection to Internet.

Aaron Wells (u-aaronw)
tags: added: html
Changed in mahara:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.