<!DOCTYPE html>
<div style="width: 100px">
<svg viewBox="0 0 100 100">
<rect width="100" height="100" fill="green"/>
</svg>
</div>
<script>
document.querySelector('svg').setAttribute('width', 200);
document.querySelector('svg').removeAttribute('width');
</script>