function download(source){
const fileName = source.split('/').pop();
var el = document.createElement("a");
el.setAttribute("href", source);
el.setAttribute("download", fileName);
document.body.appendChild(el);
el.click();
el.remove();
}
var a = $("<a>").attr("href", "http://i.stack.imgur.com/L8rHf.png").attr("download", "img.png").appendTo("body");
a[0].click();
a.remove();