The code you linked to merely changes the style of the image. It does not download more than one image, although that’s a perfectly legitimate strategy.
You can find several options for converting images to SVG format here, but this is less than optimal for any but the simplest images.
Yes … AI indeed was my tool of choice in the past when rendering (.svg) conversions. Here’s the “How-To-Article” now posted at the Carbon Free Footprint repo.