title: What to do with SVG so it can be resized using Javascript?
body: <p>Let's say I loaded SVG, displayed it in browser, and so far it is OK.</p>
  
  <p>Now, I would like to resize it. All methods I found googling failed to give me the desired effect.</p>
  
  <p>It is all variations of:</p>
  
  <pre><code>$svg.removeAttr('width')
      .removeAttr('height')
    //.attr('preserveAspectRatio','xMinYMin meet')
    //.css('width',width+'px')
    //.css('height',height+'px')
      .css('width','100%')
      .css('height','100%')
      .attr('viewBox','0 0 '+width+' '+height)
      ;
  </code></pre>
  
  <p>Nothing. I get the view of desired size, but the image (SVG) is <strong>clipped</strong> to that view instead of being <strong>resized</strong>. Setting size via attributes does not change a thing. Like the size of that SVG is carved in stone.</p>
  
  <p>Thanks to <strong>frenchie</strong> answer (see below) it appears JS tries hard to resize SVG and for basic SVG it just works. So the real question is -- what to do with SVG (real-world SVG, not just a rectangle) so Javascript would be able to resize it?</p>
  
  <p>SVG I am testing: <a href="http://jsfiddle.net/D6599/" rel="nofollow noreferrer">http://jsfiddle.net/D6599/</a></p>
  
  <hr>
  
  <p><em>I created SVG with Inkscape, and this is how I load SVG in JS:</em></p>
  
  <pre><code>$.get(svg_url, function(data) {
      // Get the SVG tag, ignore the rest
      svg = $(data).find('svg')
              .attr('id', 'SVG')
              // Remove any invalid XML tags as per http://validator.w3.org
             .removeAttr('xmlns:a')
             [0];
  
      on_load();
  }, 'xml');
  </code></pre>
  
  <p><em>The code comes from <a href="https://stackoverflow.com/questions/11978995/how-to-change-color-of-svg-image-using-css-jquery-svg-image-replacement">How to change color of SVG image using CSS (jQuery SVG image replacement)?</a>. What I have later on is <code>svg</code> element (I wrapped it using jQuery).</em></p>
  
  <p><strong>This is not the question how to load SVG, or what to do with cross-domain issue. SVG loads fine, it is the same domain as the script (my disk).</strong></p>