<!DOCTYPE HTML>
<svg width="100" height="100" style="display: none;">
<defs>
<rect id="redSquare" width="100" height="100" fill="green" />
</defs>
</svg>
<template id="template">
<svg width="100" height="100">
<rect id="greenSquare" width="100" height="100" fill="green" />
<use xlink:href="#redSquare" />
</svg>
</template>
<script>
document.body.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true));
</script>