News for hackers. Stuff that matters.
Re:I am a fast webpage by quinndupont on Wednesday September 07, 2016 @06:24PM (#12448437)
Is this image inlining thing something new? Am I reading it correctly that the images are encoded in base64 and delivered as html? Surely this is a bad idea... no?
Re:I am a fast webpage by creshal on Wednesday September 07, 2016 @06:33PM (#12448528)
> Is this image inlining thing something new?

No, it's been around since forever. Just not used terribly often.

> Am I reading it correctly that the images are encoded in base64 and delivered as html? Surely this is a bad idea... no?

It depends. Making a new request to fetch the image always has overhead. Whether that overhead is bigger or smaller than the overhead of base64-encoding the image depends on:

• file size (naturally)

• file compressibility: The difference isn't as pronounced after gzipping everything, especially if the source data is somewhat compressible

• protocol: http2 allows a correctly configured server to push attached data with the original request, so no second request is needed. Even without server push, http2's multiplexing will reduce the overhead drastically compared to plain HTTP1.1 or the worst case, HTTPS1.1 to a different domain. The latter requires a full TLS handshake, and that's what, >30kb data exchanged if you have more than one CA certificate in the chain? That's a lot of image data.

Re:I am a fast webpage by cperciva on Wednesday September 07, 2016 @06:39PM (#12448571)
You forgot the most important factor: Whether you're reusing that image on a different page. Embedding images in the HTML is basically saving an HTTP request at the expense of not being able to cache the image separately from the HTML.
Re:I am a fast webpage by 33degrees on Wednesday September 07, 2016 @06:47PM (#12448636)
You can, however, embed images in CSS, which gives you both reduced requests and caching.
Re:I am a fast webpage by mikekchar on Wednesday September 07, 2016 @08:37PM (#12449294)
Unless you inline the CSS ;-)
Re:I am a fast webpage by rocky1138 on Wednesday September 07, 2016 @08:11PM (#12449158)
This seems like it should work, but have you ever tried it? Or, can you point me to some results of a test to show that it indeed caches the image embedded in the CSS?
Re:I am a fast webpage by paulddraper on Wednesday September 07, 2016 @09:23PM (#12449500)
If it's inline, then it's cached with whatever it's inlined into.
Re:I am a fast webpage by echeese on Thursday September 08, 2016 @05:04PM (#12457327)
The problem is that now it's going to be sent with every request. So it'll make the first page faster for the initial request, but slower in the long run.
Re:I am a fast webpage by 33degrees on Sunday September 11, 2016 @09:59AM (#12473368)
I'm not sure how you figure that? The CSS file containing inline images would get cached, so nothing would be sent after the initial request.
Re:I am a fast webpage by dorfsmay on Wednesday September 07, 2016 @06:51PM (#12448677)
Exactly! On a typical site, a lot of images are reused across pages, if externalised then it's already cached in your browser.
Re:I am a fast webpage by sillysaurus3 on Wednesday September 07, 2016 @06:38PM (#12448567)
Completely offtopic, but how do you type •? I like it.
Re:I am a fast webpage by maxerickson on Wednesday September 07, 2016 @06:43PM (#12448607)
It's system dependent.

On windows you can do alt+numpad 2022

On whatever is handling input for this XFCE system, control+shift+U 2022+Enter types it.

Re:I am a fast webpage by creshal on Thursday September 08, 2016 @03:56AM (#12451089)
And since I'm lazy, I put it on AltGr+, with xmodmap.
Re:I am a fast webpage by Symbiote on Thursday September 08, 2016 @07:52AM (#12452136)
• Enable the compose key on Linux — I set the "Menu" key to be compose — then the sequence is Compose . =

Characters like →, —, €, £, ©, ™, µ, ①, ②, , °, “ and ”, … and ‽ are easily available, as well as most European-ish letter accents: àáâäąȧåảāãæ.

(I live in Denmark, but rarely type Danish. The compose key is more than adequate for typing København, Østerbro and the Æ in my street's name.)

https://en.wikipedia.org/wiki/Compose_key

Re:I am a fast webpage by erichocean on Wednesday September 07, 2016 @11:18PM (#12450044)
• is Option-8 on a Mac.
Re:I am a fast webpage by hkmurakami on Wednesday September 07, 2016 @06:43PM (#12448603)
I personally type it with a unicode keyboard input (ex: Japanese in my case) 

ex: "・"

Re:I am a fast webpage by oneloop on Wednesday September 07, 2016 @06:33PM (#12448529)
Depends. If you consider that in each request a big chunk of time is spent one opening the connection, and that you can even start opening the connection to download the linked picture after you have received the response from the first hit, then maybe it's not a bad idea. It's one round trip worth of time that you shame off the total loading time.

However, if the image is very large, it will make the initial request large as well. I would only use this for images that are small and above the fold.

Re:I am a fast webpage by Confiks on Wednesday September 07, 2016 @06:29PM (#12448478)
No, image inlining is quite old, and base64 is not a very efficient encoding, although gzip might make up for the ~1/3 increase in size.

You'd think HTTP/2 server push would stand for this, but I can imagine inlining is still a bit faster.

Re:I am a fast webpage by HugoDaniel on Thursday September 08, 2016 @01:23AM (#12450482)
The biggest problem with inlining images (imo bigger than the base64 size increase) is that when you change something (like a word in the text of the page) you are forcing your users a full reload of the page (images included). Most of these performance tips assume things won't change.

We know life doesn't work that way.

Re:I am a fast webpage by pmarreck on Wednesday September 07, 2016 @06:40PM (#12448578)
I think it depends on how much of an image we're talking about.

If it's small, the overhead from base64'ing it (if the page is gzipped) is lower than the overhead of opening a new HTTP connection just to retrieve that one image.

Re:I am a fast webpage by h4nkoslo on Wednesday September 07, 2016 @06:36PM (#12448554)
Re:I am a fast webpage by ralusek on Wednesday September 07, 2016 @06:27PM (#12448463)
There is an increase in size to base64 encode, in addition to what I assume is the lost capability to cache images, as well as load them intelligently.
Re:I am a fast webpage by chriswarbo on Wednesday September 07, 2016 @09:23PM (#12449498)
Other reasons to embed images using base64 are to have pages work standalone, to reduce complexity (no need to keep pages and associated resources in sync) and increase locality (things are defined where they're used).

These probably aren't particularly important for most sites, but it's something I do on my personal site ( chriswarbo.net ) since I care more about ease of maintenance than load times.

Re:I am a fast webpage by Sirikon on Wednesday September 07, 2016 @06:32PM (#12448515)
base64 encoding increases the size of the file.

For that image I would prefer to use inline SVG...

Re:I am a fast webpage by dahart on Wednesday September 07, 2016 @07:14PM (#12448837)
Indeed, this particular image is 3.5k of PNG, I'm certain it could easily be well under 1k as SVG.
Re:I am a fast webpage by Eric_WVGG on Thursday September 08, 2016 @11:13AM (#12453751)
not to mention retina-smoove
Re:I am a fast webpage by silverwind on Wednesday September 07, 2016 @06:31PM (#12448505)
Base64-encoding induces a factor 1.333 size increase of the byte stream, so it's likely not worth it if the site is served on HTTP2. To get exact figures, one would of course have to calculate the size of the additional TCP packet(s) and HTTP headers.
Re:I am a fast webpage by nfriedly on Wednesday September 07, 2016 @06:34PM (#12448537)
I think it depends on the image size and use case. For small images where the round trip time of an extra request would make a bigger impact than the file size, inlining them might make sense. Especially on mobile where latency tends to be higher.
Re:I am a fast webpage by dredmorbius on Wednesday September 07, 2016 @11:26PM (#12450072)
Keep in mind that you can inline images as SVG as well, which often results in smaller images, included with your HTML or CSS requests.

Not all browsers support SVG, and not all support all properties, but those that do give some pretty good results.

Re:I am a fast webpage by kensign on Thursday September 08, 2016 @03:27AM (#12450955)
pretty much every standard browser that is in use supports SVG. I've been using it for years.
Re:I am a fast webpage by Numberwang on Wednesday September 07, 2016 @06:29PM (#12448483)
You can do it with fonts too.
Re:I am a fast webpage by cousin_it on Thursday September 08, 2016 @07:40AM (#12452085)
Sounds too. <audio src="data:audio/mp3;base64,..." /> Probably videos as well, but I haven't tried it.
Re:I am a fast webpage by draw_down on Wednesday September 07, 2016 @06:33PM (#12448525)
Bad why?
Re:I am a fast webpage by pmarreck on Wednesday September 07, 2016 @06:41PM (#12448590)
because base64 encoding expands the size of a binary, presumably