<!DOCTYPE html>
<script>
function foo() {
console.log('foo is called');
}
</script>
<svg id="second">
<g id="first">
<image xlink:href="../../images/resources/green-10.png" onload="foo()"></image>
<use xlink:href="#second" x="100" fill="red"/>
</g>
<use xlink:href="#first" x="100" fill="red"/>
<rect width="100" height="100"/>
</svg>