Project

General

Profile

Actions

Feature #77048

closed

Backend: Embed SVG icons and flags in css

Added by Thomas Mayer almost 8 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Backend User Interface
Target version:
-
Start date:
2016-07-11
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

TYPO3 CMS 7 introduces usage of SVG in icons and flags. Which is great.

TYPO3 7.6 uses code like

<span class="t3js-icon icon icon-size-small icon-state-default icon-flags-de" data-identifier="flags-de">
  <span class="icon-markup">
    <img src="/typo3/sysext/core/Resources/Public/Icons/Flags/SVG/DE.svg" height="16" width="16">
  </span>
</span>

Which has disadvantages:

- Performance: One request per SVG icon/flag (compare that to sprites for .PNGs)
- URL's of icons embedded in HTML (contradicts css paradigm and blows up HTML code in size)
- Bad compression per SVG while better compression is likely over multiple SVG's (less entropy)
- Bad caching: Loading a "new" SVG still requires one request even if 99% are cached already

I suggest to encode all the icons and css into one or few css files using css syntax like

background: url('data:image/svg+xml;base64,<encoded svg>') no-repeat 1.3rem 0.25rem;

Advantages:
- a simple css class can do the trick. Like it did as of TYPO3 6.2.
- output of explicit URL (img SRC=) is obsolete
- get a better compression theoretically (larger file with bad entropy instead of many small files with better entropy per file)
- Compatibility of 7.6 and 8 without a breaking change if only css classes are used by an extension (without IconFactory or IconUtility, e.g. in javascript)
- still have all the benefits of SVG.
- improve backend's performance significantly (every time an icon is used!)

To be discussed: Browser support. I guess this is not an issue for the backend any more, at least if modern browsers can be assumed.


Related issues 3 (1 open2 closed)

Related to TYPO3 Core - Bug #76996: Language flags (css classes and sprites) got removed in 7.6.0ClosedFrank Nägler2016-07-09

Actions
Related to TYPO3 Core - Feature #69706: Add InlineSvgIconProviderClosedBenjamin Kott2015-09-11

Actions
Related to TYPO3 Core - Feature #77224: Backend: Icon registration: Cache SVG files in css fileNew2016-07-11

Actions
Actions

Also available in: Atom PDF