Page MenuHomePhabricator

Implement minification for SVG files in ResourceLoader
Open, LowestPublic

Description

This task is about implementing a high performance minifier for SVG content. It will also track the use of that minifier when embedding SVG files in file modules through CSSMin.

See Also:

Task T61086 tracks the use of this minifier (once implemented) by ResourceLoaderImage for SVGs served from that endpoint.


Original report:

This comes from bug 34810 (T36810)... Which could use this feature to dynamically do it (or the simpler older method of creating .min files)

SVG are used as non page content files, they contain a lot of whitespace. Minify and serve!

Details

Reference
bz34812

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:12 AM
bzimport set Reference to bz34812.
bzimport added a subscriber: Unknown Object (MLST).

There's several possible things to do here:

  • transparent HTTP gzip compression (can be enabled at webserver-level)
  • stripping comments and whitespace (traditional 'minification', could be done as a pre-processing step)
  • intelligent collapsing of redundant attributes and styles (harder!)
  • rounding coordinates to fewer digits
  • decimating points in overly-detailed polygons/curves

Depending on just what you're trying to do, you could do some or all of those...

For SVG fonts I'd recommend that they be relatively sane to begin with (if they're full of whitespace and comments as output assets, that's kinda lame -- they should be small/clean to begin with), and use transparent gzip compression on the web server configuration.

I think we can apply the same as PNG files.

I don't know of any SVG files we have in our repository that we manually edit to the level that can't aren't already be minified (they might have some indentation, but that's about it, and we could actually minify those in the repository, like we optimise PNG files).

I know SVG is text where PNG is not, but unless we actually edit them, it should be fine.

As for solving this bug, if we want to minify SVGs in separate requests (e.g. fonts), that would get quite tricky. They'd need a url to be served from.

As for SVGs we embed in CSS (SVGs for icons like we do in VisualEditor), those could be easily minified before being base64 encoded (that is, once we have an xml minifier).

  • Bug 63491 has been marked as a duplicate of this bug. ***
Krinkle raised the priority of this task from Low to Medium.Apr 28 2015, 5:40 PM
Krinkle updated the task description. (Show Details)
Krinkle added a project: Performance Issue.
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).

Raising priority per T59777. We're using more SVGs nowadays.

Krinkle renamed this task from Allow minification of SVG files to Implement minification for SVG files in ResourceLoader.Aug 11 2016, 12:01 AM
Krinkle updated the task description. (Show Details)
Krinkle lowered the priority of this task from Medium to Lowest.Feb 26 2023, 9:12 PM