Simple SVG markup
The <svg>
markup required to display an external source is too verbose.
<svg viewBox="0 0 512 512"><use xlink:href="path/to/image.svg#sprite"></use></svg>
It should be simple.
<svg src="image.svg#sprite"></svg>
Right now, developers must append a <use>
element with an xlink:href
attribute to an <svg>
element to pull from an external source, be it a hash on the page or an external file.
<use xlink:href="path/to/image.svg">
<use xlink:href="path/to/image.svg#sprite">
<use xlink:href="#sprite">
I suggest the spec be updated so that developers may alternatively use a src
attribute on the <svg>
element to pull from an external source.
<svg src="path/to/image.svg"></svg>
<svg src="path/to/image.svg#sprite"></svg>
<svg src="#sprite"></svg>
Secondly, right now, developers must specify the viewBox
attribute when pulling from an external source that already has it.
<svg viewBox="0 0 512 512"><use xlink:href="path/to/image.svg#sprite"></svg>
This requires developers know the viewBox
value for each SVG and add it to every <svg>
element on the page. Typically, this means the attribute is found in the external source and then duplicated several times across the page.
I suggest the spec be updated so that an <svg>
element with a src
attribute and no viewBox
attribute inherit the viewBox
value from its external source.
<svg src="path/to/image.svg#group"></svg>