Quote (waraholic @ Jan 23 2019 06:27pm)
There are benefits and drawbacks to both approaches so neither is always right.
However, in general you should save SVG and other resources in their binary format and link to them instead of transforming them into a non-binary representation and embedding them. This way you don't lose compression, the initial page loads faster, and you can update the resources without changing the code/html.
If you use img then the resource will be cached by the browser. The images will also be loaded by separate http requests. This means the page may load in images later than the page html/css/other images.
If you in-line everything then nothing is cached and the entire page will load in one HTTP request, but the page will be significantly larger in size. Images can easily be 3-6x larger when in-lined). The page MAY load faster than the above approach the first time it is visited. The page WILL load slower than the above approach if the page has previously been visited and caching is being utilized.
I think working binary resources is just easier to do. No converting. You know what they are. You can pull them from the server if you need to and modify them. I'd go with that.
PS: For mobile users using DATA URI / in-lining will almost always be slower due to the hardware and will also increase their data usage so avoid this.
Thanks a lot for your input, was really well written...You sure know your thing!
My understanding of your post is that I should use the SVG's as regular images. That leads me to the next question, is it better to use images to create shapes that could be made with CSS? (example: a Sale tag)
By the way, I hope you stick around, you are a big contribution in the programmers heaven
This post was edited by ium on Jan 23 2019 04:20pm