View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
3816 | Composr | core | public | 2019-06-10 17:59 | 2024-07-24 22:23 |
Reporter | Chris Graham | Assigned To | Chris Graham | ||
Priority | normal | Severity | feature | ||
Status | resolved | Resolution | fixed | ||
Summary | 3816: Performance-centric image overhaul | ||||
Description | We can do responsive images simply using something like width: 100% in CSS or width="100%" in HTML. This makes things mobile-friendly, but it makes things less-friendly performance-wise as it requires a page reflow once the image metadata (width and height specifically) loads. Ideally we would be able to set intrinsic width/height in the HTML, or the aspect ratio, but there's no standard yet. There's another concern about image lazy-loading. People currently do this kind of thing with JS hacks, although there's a web standard coming. The web standard is a simple binary flag, but I think a precedence setting would be better. We can resolve both the above performance areas together with a JavaScript solution. We provide the <img> with a src="data: ..." holding image that has a width/height the same as the source image. We provide HTML width="100%". This should allow the browser to paint correctly without any future reflow. We then also supply a data-src attribute which our JavaScript handles, for the real image to then be loaded on top. And finally there'd be a precedence value that defines how soon the browser should load the image relative to others. To make things easy in templating, we'd handle it via a new Tempcode symbol, {$IMG_RESPONSIVE,url[,precedence][,further-HTML-properties]}. It'd automatically construct the HTML needed, as described above. From a Comcode point of view, an img/media/attachment would be able to have the following sizing methodologies configured: 1) Intrinsic size (the HTML width/height properties are set using the existing {$IMG_WIDTH} and {$IMG_HEIGHT} symbols) 2) Specific size (the HTML width/height properties are set simply) 3) Responsive (100%) - uses the {$IMG_RESPONSIVE} Tempcode symbol defined above And there would also be a lazy-loading precedence value too. We should also extend img/media/attachment to support srcset. | ||||
Additional Information | Consider doing the same with a {$VIDEO_RESPONSIVE} symbol. For core design images, like a logo header, we would not want to have JS processing them as we want them to come before JS is loaded and parsed. This scenario is best handled by embedding the image inside the CSS (which we can already do using the {$IMG_INLINE} symbol), which should also avoid the need for a re-paint. | ||||
Tags | Type: Performance | ||||
Attach Tags | |||||
Time estimation (hours) | 8 | ||||
Sponsorship open | |||||
|
It seems just setting correct width and height HTML attributes is now going to work in modern browsers, without any new standard. So the "data:" stuff no longer applies, it will be automatic. |
|
Good article: https://www.industrialempathy.com/posts/image-optimizations/ |
|
This is a complex morass of an issue. Essentially we are talking about: - Lazy loading of images - Not having CSS repaints happen when a responsive image finally loads - srcset support for content authoring - More precise control of image sizing I'm nuking most of it on the basic of: - Overcomplexity - The web standards folks have got ahead of this issue Lazy loading is now possible with loading="lazy" on the image tag. Very simple. I think we can reasonably assume any Comcode/attachment image in Composr should be lazy loaded, because that kind of image lines up almost perfectly with the kind of thing that should be (i.e. you want content images to be lazy loaded but fundamental design images not to be). We don't need to make it configurable because the user can always customise their own HTML. *I have just added this.* I think a precedence system for lazy loading is overkill, the browser can be trusted to do this (besides, it is parallelising requests). CSS repaints was already fixed by browsers allowing CSS to tentatively assume the HTML-supplied width/height attributes in the HTML are correct hints to an images aspect ratio. A reasonable assumption that at worst creates a repaint (which would need to happen anyway) if the assumption proves wrong. srcset is obviated by people using SVG images. v11 is going in very heavy with SVG. For the small and very thin remaining case of people wanting hi-dpi support for raster images shown for content, they can hand edit their HTML. Making image sizing more precise is not really needed at the Comcode layer. At the CSS layer we now don't allow any images to overflow via our default CSS rules. Intrinsic size is the default. Specific size is possible by specifying width/height. Responsive is the default *FOR OVERFLOW*. I think that covers the vast majority of use cases without adding extra complexity. |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-06-10 17:59 | Chris Graham | New Issue | |
2019-06-10 17:59 | Chris Graham | Tag Attached: Type: Performance | |
2019-06-17 18:43 | Chris Graham | Relationship added | related to 2051 |
2019-10-23 18:08 | Chris Graham | Note Added: 0006130 | |
2019-11-15 22:06 | Chris Graham | Tag Attached: Roadmap: v12 | |
2020-12-29 17:32 | Chris Graham | Note Added: 0006879 | |
2021-02-24 18:04 | Chris Graham | Assigned To | => Chris Graham |
2021-02-24 18:04 | Chris Graham | Status | Not Assigned => Resolved |
2021-02-24 18:04 | Chris Graham | Resolution | open => fixed |
2021-02-24 18:04 | Chris Graham | Note Added: 0006967 | |
2022-08-15 15:47 | Chris Graham | Tag Detached: Roadmap: v12 | |
2024-07-24 22:23 | Chris Graham | Relationship added | related to 5539 |