Feature #77048
closedBackend: Embed SVG icons and flags in css
0%
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.