News for hackers. Stuff that matters.
Re:A 14kb page can load much faster than a 15kb page by hcarvalhoalves on Wednesday August 24, 2022 @11:07PM (#32588969)
1MB per photo is fine. It's the content after all.

Many sites today will load 10MB of JS and custom font crap alone, just to show a few paragraphs of text.

I don't think the point is the size itself, but it's the content vs. bloat ratio.

Re:A 14kb page can load much faster than a 15kb page by philliphaydon on Thursday August 25, 2022 @12:47AM (#32589605)
Omg just disabling custom fonts in Firefox speeds up the internet so much!
Re:A 14kb page can load much faster than a 15kb page by blep_ on Thursday August 25, 2022 @01:02AM (#32589712)
I wish I could do this without breaking all the obnoxious sites that use fonts for icons.

Someone should invent an HTML tag for putting images on a page.

Re:A 14kb page can load much faster than a 15kb page by cuu508 on Thursday August 25, 2022 @02:28AM (#32590294)
I'm using icon font to show a grid of icons, where each icon can be clicked to toggle it "on" or "off". Example: https://i.imgur.com/EHYHVDw.png

When I was implementing this, I initially experimented with the img tags – easy to implement, easy to have multi-color icons. But the grid can potentially have 100s of rows, potentially resulting in 1000+ of img tags. When testing with img tags, my site became noticeably sluggish (on a quick desktop PC). With icon fonts, the icon grid is basically lines of text, and the browser can render it with no noticeable performance impact.

Re:A 14kb page can load much faster than a 15kb page by 8n4vidtmkvmk on Thursday August 25, 2022 @02:53AM (#32590457)
i too use an icon font, but if you want images you should use a spritemap. it shouldn't be sluggish.
Re:A 14kb page can load much faster than a 15kb page by EGreg on Thursday August 25, 2022 @07:39AM (#32592337)
I write a framework, not an app. In any event, I need to allow others to style my icons with their own colors. Hence I use a font. Is there a way to use SVG sprites or something, while also letting people control the stroke color with css? Seems yes: dont put CSS in the svg. But why not just use a font?

https://stackoverflow.com/questions/37940282/changing-the-st...

Re:A 14kb page can load much faster than a 15kb page by 8n4vidtmkvmk on Thursday August 25, 2022 @09:22PM (#32602239)
Yes, you can even put `color: currentColor` in your SVG file and then color it exactly the same way as your fonts (it'll use the current text color).

Why not? I don't know, you're asking the wrong person, I use a CSS font too. My reasons are (a) last time I looked into putting SVGs into a sprite-map to avoid 1000 HTTP requests it was a shitshow (not well supported), and (b) Chrome and other browsers would sometimes align the SVG on a half-pixel causes the edges to be a little blurry, whereas fonts get special treatment to ensure they are crisp. That was years ago tho.

Re:A 14kb page can load much faster than a 15kb page by kroltan on Thursday August 25, 2022 @08:16AM (#32592669)
If you can create a customized font file that is tiny and only has the icons you actually use, sure.

But the "wrong tool for the job" point still stands, users with custom fonts disabled (for performance or accessibility reasons) will not be able to see your icons.

Re:A 14kb page can load much faster than a 15kb page by easrng on Thursday August 25, 2022 @09:45AM (#32593624)
SVG with <use> tags should work perfectly.
Re:A 14kb page can load much faster than a 15kb page by tastemykungfu on Thursday August 25, 2022 @01:06AM (#32589738)
A lot of icon frameworks are moving to SVG embedded on the page. Better usability - compared to the lazy fontawesomes out there.
Re:A 14kb page can load much faster than a 15kb page by manmal on Thursday August 25, 2022 @02:22AM (#32590251)
Fontawesome is also available as SVG.
Re:A 14kb page can load much faster than a 15kb page by philliphaydon on Thursday August 25, 2022 @02:37AM (#32590351)
I just accept some things break for icons, but hovering over usually shows what the button is.

The only annoying thing about turning off fonts is the weird settings ProtonMail and GitHub use.

https://prnt.sc/zoPQiiPKIeZy

Re:A 14kb page can load much faster than a 15kb page by hiyer on Thursday August 25, 2022 @02:16AM (#32590214)
Thanks for the tip! For others wondering how you can do this, go to Settings -> Fonts -> Advanced, and uncheck "Allow pages to choose their own fonts...".
Re:A 14kb page can load much faster than a 15kb page by xigoi on Thursday August 25, 2022 @07:21AM (#32592198)
Or use uBlock Origin, which will allow you to re-enable fonts if disabling them breaks a site.
Re:A 14kb page can load much faster than a 15kb page by markdog12 on Thursday August 25, 2022 @04:25PM (#32599522)
I wish you could do this with Brave (without uBlock Origin).
Re:A 14kb page can load much faster than a 15kb page by UI_at_80x24 on Thursday August 25, 2022 @10:52AM (#32594429)
After reading this fine tip, I did the same thing. Thank-you for the suggestion.

For others wondering how:

about:config

gfx.downloadable_fonts.enabled (set to to FALSE)

Re:A 14kb page can load much faster than a 15kb page by throwaway563 on Thursday August 25, 2022 @02:10AM (#32590175)
how do you disable fonts? Plugins?
Re:A 14kb page can load much faster than a 15kb page by philliphaydon on Thursday August 25, 2022 @02:38AM (#32590358)
Can check the comment from hiyer, that's all I did. Just be aware sites that use fonts for icons will look a bit weird.
Re:A 14kb page can load much faster than a 15kb page by soperj on Thursday August 25, 2022 @02:30AM (#32590308)
uBlock Origin has that option.
Re:A 14kb page can load much faster than a 15kb page by UI_at_80x24 on Thursday August 25, 2022 @10:54AM (#32594456)
about:config gfx.downloadable_fonts.enabled (set to false)
Re:A 14kb page can load much faster than a 15kb page by ta-run on Thursday August 25, 2022 @05:11AM (#32591367)
What's the substitute to not using custom fonts? Or is there a better way to load it? I'm having a hard-time convincing our brand team to defaulting to a system font.
Re:A 14kb page can load much faster than a 15kb page by kevincox on Thursday August 25, 2022 @08:56AM (#32593103)
For most things just using the user's configured font is almost as good, if not better. For cases where you really want to make something stand out custom fonts can be nice but you can also try using "font stacks" that the user has already installed.

In general I recommend using the default font for "body text" because you know it is something that the user finds easy to read. For headings, buttons and smaller strings of text you can be more creative but even then you can consider things like trying system fonts first and deferring the custom font load until after the content.

Re:A 14kb page can load much faster than a 15kb page by nirimda on Thursday August 25, 2022 @10:22AM (#32594088)
> In general I recommend using the default font for "body text" because you know it is something that the user finds easy to read.

A lot of users don't know how to or can't change the default font. For instance, I have no idea idea how to change the default font on my phone, or even if I can. It's probably better to say "at least you know it's something that was selected to be at least tolerably usable by most people, which cannot be said of the design team's fancy spindly small-x font".

Re:A 14kb page can load much faster than a 15kb page by lexicality on Thursday August 25, 2022 @05:24AM (#32591444)
Convince the brand team to pick a couple fallback system fonts and swap the brand font in after it has loaded. You will have a bit of content reshuffling no matter what you do but it's better than the alternative. There are directives to do this in pure CSS but I seem to remember they had some unfortunate implementation bugs so when I did this it was easier to do it in JS.
Re:A 14kb page can load much faster than a 15kb page by smoe on Thursday August 25, 2022 @07:31AM (#32592276)
There is some interesting things you can do with font-display and other css properties. E.g hide text for up to 100ms, if custom font has loaded swap to it, if not use fallback font.

https://simonhearne.com/2021/layout-shifts-webfonts/

Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @12:09AM (#32589380)
1MB per photo is massive. Its easy to compress photos down to 100KB or less.
Re:A 14kb page can load much faster than a 15kb page by bscphil on Thursday August 25, 2022 @03:03AM (#32590519)
This is simply false, even if you mean using AVIF.

Here's a test case, using a moderate sized (3000x2000) image. Nothing ridiculously huge or anything, and it's not an especially complex image. I'm linking the best I can do for both JPEG (at 200 KB) and AVIF (at 100 KB). If you can create a passable versions of these images at 100 KB with either codec (or WEBP for that matter), please do show us how.

Original image: https://0x0.st/o9x5.png

JPEG (200 KB): https://0x0.st/o93i.jpg

AVIF (100 KB): https://0x0.st/o9xC.avif

Maybe JPEG XL will get us closer, but not all the way there, that's for sure: https://0x0.st/o9xd.jxl - JPEG XL is intended for high quality images, so it is not optimized for this kind of extremely low bitrate (~0.1 bpp) usage.

Re:A 14kb page can load much faster than a 15kb page by theandrewbailey on Thursday August 25, 2022 @08:52AM (#32593049)
> JPEG XL is intended for high quality images, so it is not optimized for this kind of extremely low bitrate (~0.1 bpp) usage.

It's better than AVIF at low bitrates. I did a comparison of the latest builds 3 months ago, and was amazed that JPEG XL has more detail than AVIF at 0.05-0.1 bpp (~120KB 1080p). It's a bit subtle, but I could see it. Once browsers ship full support (at least Firefox + Chrome), I'll be on board.

Re:A 14kb page can load much faster than a 15kb page by bscphil on Thursday August 25, 2022 @05:32PM (#32600215)
> and was amazed that JPEG XL has more detail than AVIF at 0.05-0.1 bpp (~120KB 1080p)

bpp = bits per pixel, not bytes. At 1080p, "0.05-0.1 bpp" is 13-26 KB. Much smaller than what you were testing. Might want to recheck your sizes, if you are actually looking at 0.5 bpp it would not surprise me at all that you found JPEG XL superior.

At very small sizes like 0.1 bpp the results are debatable, but I think AVIF is a pretty clear winner if you aren't too bothered by blurring. Samples at 0.15 bpp:

https://afontenot.github.io/image-formats-comparison/#air-fo...

https://afontenot.github.io/image-formats-comparison/#citroe...

https://afontenot.github.io/image-formats-comparison/#festa-...

Re:A 14kb page can load much faster than a 15kb page by Seirdy on Saturday August 27, 2022 @03:29PM (#32622271)
In the experimental Document-Policy HTTP header, "bpp" does seem to signify bytes per pixel.

Document-Policy explainer: https://github.com/wicg/document-policy/blob/main/document-p...

I tried it out on my own site, and through trial-and-error I found that Chromium does in fact treat the "max-bpp" Document-Policy directives as bytes-per-pixel.

I could be wrong; my memory has faded. Please correct me if this is the case.

Re:A 14kb page can load much faster than a 15kb page by bscphil on Wednesday August 31, 2022 @09:13PM (#32670545)
I'm not sure what HTTP headers have to do with anything. Using "bpp" to mean bits per pixel is extremely common in image encoding. See e.g. https://en.wikipedia.org/wiki/Color_depth where an uncompressed image is often 24 bpp (8 bits per channel). It's also common to use bitrate (rather than byterate) in audio encoding, see e.g. https://wiki.hydrogenaud.io/index.php?title=Bitrate
Re:A 14kb page can load much faster than a 15kb page by cuu508 on Thursday August 25, 2022 @04:16AM (#32591015)
Downsize the 3000x2000 to the dimensions it will be displayed at and you will be able to go below 100KB.
Re:A 14kb page can load much faster than a 15kb page by bscphil on Thursday August 25, 2022 @04:24AM (#32591072)
What if it will be displayed at 3000x2000? I mean that's the whole conversation here, we're talking about images that are the focus point of the page.
Re:A 14kb page can load much faster than a 15kb page by cuu508 on Thursday August 25, 2022 @04:44AM (#32591195)
Yes, then 100KB is usually not enough.
Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @04:09AM (#32590963)
I normally deal with 720P images for internet distribution. For 3000x2000 that would be around 230KB to 250KB.
Re:A 14kb page can load much faster than a 15kb page by bscphil on Thursday August 25, 2022 @04:35AM (#32591152)
You replied to a thread about a photography website. I don't think 720p images are the norm for that use case.

In any event, I don't think the AVIF result at 250 KB is acceptable for photography either: https://0x0.st/o93a.avif - There's a ton of smearing and blurring that's very obvious when you're viewing the image at full size.

Re:A 14kb page can load much faster than a 15kb page by IMTDb on Thursday August 25, 2022 @04:44AM (#32591191)
3000x2000 basically means "fullscreen on a retina display @ full resolution". You can only reasonably show one picture like that at a time. So it's completely OK to have the currently displayed picture at that resolution/size.

But all photo should be loaded at a much lower size, initially, and only downloaded at full size the the user puts them in full screen.

Re:A 14kb page can load much faster than a 15kb page by Wowfunhappy on Thursday August 25, 2022 @08:22AM (#32592734)
I know lazy loading is in vogue, but as a user it only ever seems to create problems for me. I’d much rather the website download all the images ahead of time on page load, so I don’t have to wait for full quality versions each time I full screen a different image.
Re:A 14kb page can load much faster than a 15kb page by IMTDb on Thursday August 25, 2022 @08:55AM (#32593086)
This is the restaurant equivalent of : "We are at an all you can eat buffet, let me take 10 plates even if I only realistically will eat 4, so that if I want any more I don't have to stand up again".
Re:A 14kb page can load much faster than a 15kb page by docmars on Thursday August 25, 2022 @09:43AM (#32593606)
While the other way (loading each image as you view them, or lazy) is functionally equivalent to waiting in line for each separate dish, which isn't quite so fun.

Maybe gallery sites could consider offering a preference to load all images upfront if you intend to view them all.

A good example would be housing sites, where viewing higher quality photos of each listing is a primary use case.

Re:A 14kb page can load much faster than a 15kb page by NavinF on Thursday August 25, 2022 @01:02AM (#32589718)
Wat.

1MB per photo is tiny when the photo is the content. You need ~100KB for a high quality 512x512 WebP. AVIF will be slightly better but still doesn’t have universal support.

We’ve had 4K (8MP) screens for a decade now and normal DSLRs shoot 25MP so you can zoom in.

Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @02:32AM (#32590321)
Bandwidth is extremely carbon intensive. Someone viewing a couple of few 25MP images online could use 20g to 100g of CO2 (depending on compression).
Re:A 14kb page can load much faster than a 15kb page by lozenge on Thursday August 25, 2022 @04:57AM (#32591277)
We create 40kg of CO2 a day each through our diet, transport, consumption and other energy use. The idea we need to target our energy burden on Internet routers is absurd.
Re:A 14kb page can load much faster than a 15kb page by docmars on Thursday August 25, 2022 @09:48AM (#32593672)
I lament the day this becomes policy to regulate average internet usage due to a few religious fanatics who fail to understand that higher levels of CO2 enrich the Earth, and that science has been sabotaged to suit political ambitions fueled by fear porn.
Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @05:41AM (#32591532)
14 tons per year is pretty high. Most calculators estimate my usage at 6 tons per year.
Re:A 14kb page can load much faster than a 15kb page by lozenge on Thursday August 25, 2022 @07:50AM (#32592439)
The US average is 15 metric tons and that's production-based, ie counting exports and not counting imports. If you count imports and stop counting exports it would be higher. Now the US does rank highly in this measure but that's also where the 'typical' HN reader is. The typical reader is also well off which can make a huge difference(flights etc).
Re:A 14kb page can load much faster than a 15kb page by ChrisRR on Thursday August 25, 2022 @03:58AM (#32590904)
And how much carbon would they use having those photos printed out and mailed to them to look at?

Given that they could be streaming 1080p video instead, I think viewing a few photos is a relatively harmless hobby

Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @04:05AM (#32590939)
Physical item that can be looked out for 20 to 50 years vs a digital image. Not the same thing.
Re:A 14kb page can load much faster than a 15kb page by tracker1 on Thursday August 25, 2022 @07:04AM (#32592093)
The bandwidth used for single images is dwarfed... massively by streaming video content... I don't think it's a use case that is worthy of excessive time/effort to optimize for size because of bandwidth cost/effects.

edit: I'm not saying don't do it if you can get away with a smaller image dimension, or do basic optimizations... but if your concern is the environmental impact from a simgle high-resolution image from a photography site, you're putting the emphasis in the wrong place.

Re:A 14kb page can load much faster than a 15kb page by ttoinou on Thursday August 25, 2022 @03:11AM (#32590569)
Source ?
Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @03:33AM (#32590733)
https://www.emergeinteractive.com/insights/detail/does-irres...

In the US as of 2020, it was 3KG CO2 per GB Data.

Re:A 14kb page can load much faster than a 15kb page by cosarara on Thursday August 25, 2022 @04:13AM (#32590989)
I don't agree with the reasoning presented. It takes the estimate for the amount of energy that it takes to run the internet infrastructure and clients (141GW * 8765h in a year = 1235865 GWh), divides it by the amount of data transferred yearly (241 billion GB) and gets to 5.12kWh/GB.

You might argue that if people download more data, more equipment needs to run to enable it, but really all this energy consumption is happening regardless of my PC being idle or saturating its fiber pipes with torrents. If your website weights 14kb, all this same equipment needs to be on for my PC to load it.

Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @04:37AM (#32591158)
The website usage on the client side is more to do with resource usage. Unnecessary usage of Javascript is often what makes websites laggy.

You computer will normally down-clock (you can turn this off in the bios) when under lighter loads.The difference between a JS-free webpage and a bloated web page that uses multiple JavaScript with extra Javascript for ads and tracking could be around 10W/H to 40W/H on Desktops.

Re:A 14kb page can load much faster than a 15kb page by cosarara on Thursday August 25, 2022 @05:12AM (#32591373)
I agree with this. I was disagreeing with the statement

> Bandwidth is extremely carbon intensive.

and the reasoning that supports that statement.

Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @05:45AM (#32591548)
If people used less bandwidth, less new equipment would be bought to serve the increasing demand. Less bandwidth = Less carbon.
Re:A 14kb page can load much faster than a 15kb page by cosarara on Thursday August 25, 2022 @06:46AM (#32591965)
Maybe, or maybe the new equipment is much more efficient than the one it's replacing. It sounds true, but you can't really tell if it is or not, and really my annoyance is in saying it costs any estimated amount of energy, or carbon, to transfer 1GB of data. It does not, the transfer itself is basically cost-less. What costs money is running the infrastructure that makes it possible, and that's much harder to measure.
Re:A 14kb page can load much faster than a 15kb page by ttoinou on Thursday August 25, 2022 @12:42PM (#32596317)
What matters is the marginal consumption. It should be really small. Averages don't mean much. I can download one GB of Data for almost free, I doubt I would burn 3 kg of CO2 doing that
Re:A 14kb page can load much faster than a 15kb page by bmacho on Thursday August 25, 2022 @04:10AM (#32590968)
And who pays for that?
Re:A 14kb page can load much faster than a 15kb page by bigiain on Thursday August 25, 2022 @12:25AM (#32589456)
If it’s an illustrative photo for an article, sure.

If it’s a gallery photo for a site promoting a photographers skill or library, nah…

Re:A 14kb page can load much faster than a 15kb page by kjkjadksj on Thursday August 25, 2022 @12:41AM (#32589573)
Its best to have a compressed low res thumbnail that you can click to open the full resolution file in another tab imo
Re:A 14kb page can load much faster than a 15kb page by innocenat on Thursday August 25, 2022 @02:31AM (#32590311)
That 1MB is the full resolution image you open in another tab.
Re:A 14kb page can load much faster than a 15kb page by xigoi on Thursday August 25, 2022 @07:25AM (#32592231)
In that case, it shouldn't be counted into the webpage weight.
Re:A 14kb page can load much faster than a 15kb page by habibur on Thursday August 25, 2022 @12:17AM (#32589409)
Wondering how. The banner image won't be displayed by Facebook or Twitter unless it's 1200x650 in size.
Re:A 14kb page can load much faster than a 15kb page by tomschwiha on Thursday August 25, 2022 @12:25AM (#32589457)
Webp could be worth trying. Stripping metadata also. If staying with jpg - Jpgoptim could help.
Re:A 14kb page can load much faster than a 15kb page by worldofmatthew on Thursday August 25, 2022 @12:22AM (#32589445)
I done photos larger than that at closer to 50KB with AVIF. 100KB with JPEG should be doable.