title: Relative to absolute image src in JavaScript
body: <p>I need to convert all src attributes of all images on the page from relative url to absolute, so basically just to add the base url on the current src.</p>
  
  <p>I know how to do that using jQuery, but I need to do it with pure JS.</p>
  
  <p>Any example or idea how to do that?</p>
  
  <p>In jQuery I'll do it like:</p>
  
  <pre><code>$('img').each(function() {
    var urlRelative = $(this).attr("src");
    var urlAbsolute = 'https://example.com' + urlRelative;
    $(this).attr("src", urlAbsolute);
  });
  </code></pre>