Optimized SVG for CC BY-NC Attribution-NonCommercial License Logo (includes base64 option)
By David Hoicka
See GitHub Page: https://github.com/david-hoicka/creative-commons-cc-by-nc-svg-optimized/
This article discusses how to improve Pagespeed website loading for Creative Commons Attribution-NonCommercial (CC BY-NC) by using optimized SVGs and Base64 Data-URIs.
Accessibility is also improved using ARIA attributes and tags.
This article outlines 4 ways to optimize SVG image logos for Creative Commons Attribution-NonCommercial (CC BY-NC).
Why use SVG? SVG images often use smaller files. SVGs scale readily as vector images. SVGs can be programmatically controlled and modified.
The Creative Commons CC BY-NC SVG image included here is optimized at about 1.5 kb, smaller size for faster HTML page loading than some commonly used Creative Commons CC BY-NC images.
In addition, although Base64 is generally slightly larger than the original SVG, using Base64 CSS Data-URIs can eliminate one or more HTML requests, as the image data can be cached in the CSS, thus speeding page load and Pagespeed.
Kindly refer to page source view for code details.
In this first example, the SVG logo for Creative Commons CC BY-NC is placed inline as an HTML5 <SVG> element:
In this second example, the SVG logo for Creative Commons CC BY-NC is inserted from a separate SVG file using an HTML5 <IMG> element:
In this third example, the SVG logo for Creative Commons CC BY-NC is inserted as a background-image using CSS:
The SVG image size can be set using CSS. For example, this image size is set to 90px x 30px using CSS:
Next, the image size can be changed by setting CSS width and height to 14em x 5em, and the enlarged SVG image generally remains crisply rendered:
In this fourth example, the SVG logo for Creative Commons CC BY-NC is inserted as a background-image using a base64 data-URI in CSS. One would think that an unencoded SVG text would work as a data-URI; however, browser support for unencoded SVG text data-URIs is variable.
As a further point of interest, this Example 4 creates a clickable background-image link:
Similarly, the SVG image size can be changed by setting CSS width and height to 14em x 5em, and the enlarged SVG image generally shows as crisply rendered:
As shown above, there are several common options for SVGs in HTML5 webpages, each with pros and cons.
Here are the download links: