Hacker News new | ask | show | jobs
by AndrejM 5902 days ago
I'm not a web developer, but could html5/javascript replace the need for some static images? For example, simple text logos. While a text banner could take several dozen KB's, some form of drawing javascript code could take only a fraction of that. Unless I'm misinterpreting how html5 works. :)
3 comments

And lay out your "images" via CSS and try to make it work on all browsers? On top of that, for a complex image, you'll end up encoding your image data in JS or HTML or some other text format, which would take up much more space than a format like JPG/PNG/GIF. Those formats are designed to handle images and that's all they do.

Plus, with JS you wouldn't necessarily get immediate rendering of the image, so you would be making the UX worse, not better.

That is not what I meant, actually. I meant rendering a logo via some paint methods, where all the information the methods have is some text, color and style attributes, etc. Then the logo gets drawn on-the-fly by the user's browser. It could work for simple logo's, I believe.
This is worth a try for a lot of reasons. If not for logos, then for buttons on your site. When I switched to painted buttons vs images in my downloadable desktop software, I (1) saved a lot of space on downloads, and (2) saved a TON of time whenever I wanted to add a new button or change the color scheme, or gradient, or shadow, etc. Re-creating each button (even just creating a new one) was a total pain in the ass compared to simply instantiating a new button or playing with the paint method.

I haven't tried it in html5 yet, but if I use buttons on the page I will definitely give this a shot.

Yes, but everything you describe can be done with CSS as well: loading custom fonts, background colors, even gradients.
Logos should be easier to copy and paste because people do that a lot. Think of a journalist writing an article about some site, if he needs a image he might use your logo. Also, Facebook uses images on the page when you post a link to identify that link.

There are so many reasons for a logo to be an image.

Or you could just use svg