Out with the JavaScript, in with the HTML
37 points
19 days ago
| 4 comments
| blog.jim-nielsen.com
| HN
zamadatix
18 days ago
[-]
I feel like the option for simplicity lies between "web component" and "make 4 pages". Something near "the button changes the CSS variable controlling the size".

You lose out on pre-downscaled images but gain that the images look sharper for high DPI users and don't have to maintain the image sets or deliver multiple copies when the size changes.

reply
recursivedoubts
18 days ago
[-]
the web platform is making slow and not-so-steady progress as a hypermedia system, but things do seem to be picking up a bit

we are working on a proposal to bring more general transclusion and a few other things here:

https://triptychproject.org

reply
DLA
18 days ago
[-]
Love this approach and use it often, usually with a Go backend. Blazing fast, simple, respects the way the web is supposed to work. Really nice touch using the CSS transitions.
reply
paularmstrong
18 days ago
[-]
This is a weirdly unpopular opinion here when it comes to HTML & JS, but there's a time and place for everything. This is a neat small example, but hardly worth the effort of changing something that was already working fine.

With the change, I now need another roundtrip network request to get new sizes of the same content on the current page that would have been able to be done in just a couple hundred bytes of JavaScript.

Edit: also there is still no view-transition support on Firefox.

reply
jakelazaroff
18 days ago
[-]
You would have needed the round-trip network request anyway to get the new images, no?

The lack of Firefox support isn't a big deal because this is a progressive enhancement. Firefox users will still be able to switch icon sizes; they just won't see the fancy transition.

reply
zamadatix
18 days ago
[-]
> You would have needed the round-trip network request anyway to get the new images, no?

It'd be a shared round trip request for all images (so long as you aren't still using HTTP/1.1) in the 1st example vs a request for the immediate images and then a separate page load.

Both have their upsides/downsides depending on the rest of the page and how users usually use it.

reply
paularmstrong
18 days ago
[-]
The images will always need a network request, but the non-JS version requires another request for the new HTML source.

And with the previous implementation, all users would get the progressive enhancement, not just non-Firefox users.

reply
jakelazaroff
17 days ago
[-]
Compared to all the new icon images on the page, that request for the new HTML source is probably negligible.

With the previous implementation, all users would get the progressive enhancement… except non-JS users :) https://www.kryogenix.org/code/browser/everyonehasjs.html

reply