Standards from the Field
The fastest code is code you never ship
After the host introduces him, Scott Jehl explains why rising code transfer sizes make native browser features a performance opportunity. He recalls how jQuery aimed to make itself obsolete and argues that developers can bring firsthand knowledge of user problems to standards discussions.
Why HTML video needed lazy loading
Jehl traces a Squarespace hack-week project back to an HTML issue he filed about lazy-loading video. He contrasts the adoption of native lazy loading for images and iframes with the bandwidth cost of offscreen video and the JavaScript developers ship to defer it. He also explains why a native feature should defer autoplay until the video approaches the viewport.
From a hack-week prototype to a responsive video revival
The hack-week team reuses the familiar loading attribute and drafts a spec change, tests and browser prototypes. To illustrate why compatibility matters, Jehl recounts how HTML lost and regained media attributes on video sources, then describes recovering Firefox's old implementation from source history. He demos a video that serves portrait and landscape crops from separate sources.
How an HTML proposal earns browser support
Jehl follows an HTML change from its first issue through spec edits, Web Platform Tests, browser vendor positions and an MDN documentation request. He explains how tests, prototypes and spec writing can inform one another early in the process.
The review that brought audio into the standard
Working-group feedback prompts the team to extend lazy loading to audio because both audio and video share the HTMLMediaElement interface. Jehl describes how the team updated the spec, tests and implementations, credits browser and community contributors, and reports the proposal's advancement to stage four.
Lazy media in practice
Jehl demos how native lazy loading defers media requests, poster images and autoplay as elements approach the viewport. He explains how it interacts with preload, why hidden audio cannot rely on viewport-based loading and why an LCP video or poster should load eagerly. He closes by showing how Squarespace exposed the feature in its CMS.
Designing a better video poster
Jehl introduces a proposal to give video posters responsive image selection, art direction and alternative text. He explains how existing fallback images forced the team to make the behavior opt-in, and how a proposed poster element preserves the existing poster attribute for older browsers.
Responsive posters you can see and hear
Jehl demos a Chromium prototype that selects different poster sizes and crops, reports the selected image through currentPoster and supports lazy loading and fetch priority. Using VoiceOver, he shows how alternative text can describe the visible frame and explains the proposed accessibility-tree behavior and video preview role description.
What if video and audio could adapt after page load?
Jehl proposes rerunning media source selection when the viewport changes after page load. His JavaScript prototype switches a playing video to a different crop while preserving playback position, and his audio demos use viewport changes to switch between layout guidance and between musical pitches.
Use field data to find the next web standard
Jehl urges performance engineers to use their dashboards and repeated implementation work to spot patterns browsers could handle natively. Drawing on Yoav Weiss's experience with responsive images, he encourages developers to file issues, try local browser changes and work directly with browser vendors.
Another person who knows a lot about how the web evolves is of course our next speaker, Scott Shell, who has also been around, a long time, who has written books on things like web components, who has done a ton of accessibility work, and who has contributed to the platform in terms of standards with things like responsive images and more recently in a variety of ways for video on the web. It's because of this, especially that for Scott, the pointing device that I brought, let me check, there we go.
The pointing device is actually a fantasy sword. A fantasy sword inspired by the Conan the Barbarian movies. Right? For two reasons. One, because for a long time, for me at least, the idea of performance video on the web was a fantasy itself, right?
It was more like something you would only think of in a dream, much like Conan himself. And it's only because of people like Scott that this dream is now finally becoming a reality on the web. The second reason is that I've myself been involved in standards work and I know it requires a lot of grit, a lot of strength, lot of willpower to get through that long standardization process and I think those are qualities that Conan himself would also appreciate.
So Scott, would say, channel your inner Arnold Schwarzenegger and tell us about web standards.
Thank you. Thank you so much. Hey everyone. I guess this is not as long, but I could... It's floppy too. I have a laser pointer, so I'll just do both. Alright. It's it's an honor to be back here presenting at...
I'm gonna set this down at perf now. It's it's hard to think of of many places where you have so many people in one room who shape the way that we deliver websites quickly and resiliently. This talk will mention a lot of those people who you'll encounter as you engage with the web standards process.
This will also be a talk about that process itself. So I'll be showing some new features that we can use today and some features that are still in planning to talk about how the process of planning them works and hint at maybe some things that we might be able to use in the future. And by the end, I hope to show you that any of us, with me as your as your example, can contribute to web standards and why I think more of us probably should.
This year has been wild. Right? I've been making websites for a couple of decades. This past year has been like unlike any other. I think our field has always sort of declared change as a constant. It's always changing, but our practices have never really changed so suddenly and dramatically, I think, as as this moment.
Maybe you're excited about that change. Maybe you're resisting it. Maybe you're doing whatever you can to collaborate with your team, effectively. I sort of bounce between all three. I think ultimately it sort of doesn't matter. Regardless of how you approach this moment, our work is changing around us. To a lot of us, that change has felt threatening, think, but as much of...
As much as our work is changing, many of the challenges of the performance engineer remain. As much as our automation... As much as automation is trained on our workflows, it hasn't really changed many of the the performance problems, the challenges that users face, the problems that demand our work. It hasn't made networks faster or more reliable, clearly this week, for audiences around the world to download and run increasing amounts of code.
So while our practices are changing quickly and code itself might be getting a little cheaper, the bytes are still expensive. And the number of those bytes is certainly not decreasing. As Tim points out here, the introduction of generative coding tools coincided with a pretty dramatic increase in, code transfer size on the web.
Indeed, what did happen in May 2025? Did Gemini answer you, Tim? Where is Tim? I don't know if that's how it works on blue sky anyway, but no matter who is to blame, line count is ever on the rise, and concerns about maintaining quality are real and abundant. So all the while, our job as performance engineers continues.
We still need to find ways to ship less code, more efficient code, more reliable and resilient code. That's why I think standardization itself is the ultimate performance best practice. It's been said many ways that the fastest code is code that never needs to run at all. Right? Or for us, never needs to ship.
What's better for performance than taking a useful pattern that we all download over and over and making it run natively in the browser instead? As web developers, we pride ourselves in in cultivating good patterns. Right? For decades, we've been freely sharing everything we know, open sourcing our code, blogging our thoughts, codifying our best practices into standards is just further along that same path, I think.
My first introduction to this came during my time on the jQuery team which was quite a while ago. John Resig used to say to us that the goal of the JavaScript library that we're building is to make itself obsolete. This was planned obsolescence but not in the classic sense like a light bulb that burns out, you know, too soon so you have to go buy another one.
Although admittedly, I have seen websites that use more than one jQuery. On the web, we can make our best tools obsolete and better and faster and more reliable by standardizing them, building patterns into the browser so our users never need to download them again. And the reason you don't need jQuery today, famously, is because that goal worked. Right? JQuery's greatest hits are built right into your browser, Query selector all, things like that.
In an episode of What The Spec podcast, which is really great, I'd recommend checking it out, Keith Circle made the case for more web developers to get involved in the standards process. Keith said, after getting involved, I was really woken up to the idea that we need more web developers in these standard bodies. We need more web developers talking to browser vendors.
As web developers, I think we understand the problems our users face and where our tools fall short. And as performance engineers, specifically, we have quantitative visibility into what's working and what isn't. And I think standards work is more accessible than many people assume. It can also provide somewhat of a counter to all the change that's happening right now because standards are meant to last. As chaotic as our field can be, the care and debate and deliberation and craft and a bit of arguing as well, that we all love, still thrives in standards.
So I wanna use some recent experience to shed light on that process a little bit, and show how we can sometimes aim beyond our own websites, when the occasion calls for it. At Squarespace, I'm a performance engineer and I've recently found myself adding a little standards work to the list of things I do. Millions of websites run on our platform, each built a little differently.
With tools like performance monitoring, we have broad visibility into how all those millions of websites are performing, what's working, where the bottlenecks are, which ones are causing the the most problem. Our teams are constantly pushing the boundaries of the web's capabilities to offer new tools and patterns to our customers and occasionally those boundaries reveal a limitation, an opportunity for the web's native capabilities to grow.
And last fall, we took advantage of one of these opportunities to further an idea that we hoped would benefit the web platform but also our own products as well. At Squarespace, we had this semi annual hack week where we get to basically work on anything. It's a really amazing perk. And last fall, that that hack week, a group of engineers joined me based on a vague description to make a contribution to web standards as our goal.
But I actually had a particular aim in mind that I hoped we could take a look at and that was lazy loading for HTML video. So about a year before the hackathon, I had filed an issue against the HTML standard suggesting that video lazy loading be supported. And the issue had a pile of thumbs up, which is like currency in web standards world.
So developers liked it, it wasn't really getting any movement yet on the on the standard side of things. So I hoped we could change that. For context that maybe no one in this room needs, I'm just gonna recap what lazy loading is real quick. Broadly speaking, it's a pattern to download... To delay downloading resources until they're needed.
Right? So since 2019, standard HTML has offered authors the ability to delay requests for images and iframes until they're visible on the page either by scrolling them into the viewport like this shows or revealing them in a menu or a tab or a carousel right when they're needed. And for images and iframes, this loading equals lazy attribute is all you needed to get that behavior.
So that alone will tell modern browsers to only load the image when it's visible. It's simple, declarative HTML to achieve a pretty complex task. So it's really nice. Lazy image loading, works great and it's no surprise that adoption has been, really good. HTTP archive says that, over 45 of websites in its crawl use loading equals lazy, which is higher than I expected.
Pretty amazing. CMSs and libraries are responsible for driving a lot of that adoption. Right? Like, they codify good patterns into their tools. So we see it used widely and this has saved truckloads of bandwidth and it helps page loading performance as well by freeing up resources for other things to load quickly.
But despite the success of image lazy loading, the the video element had no similar standards based mechanism. By default, browsers simply load some or all of a video source file and its poster image regardless of whether it's in view. And that's left developers with no native options to prevent these resources from downloading just until they're needed.
So they've needed to mimic that with JavaScript as we do. Each website, you know, asking its users to download code to do essentially the same thing across many websites, written just a little differently, each time which impacts speed, maintenance, and fragility. Downloading videos and poster images that are never going to be seen is a big waste of energy at Internet scale.
As the archive shows, video formats are the heaviest asset asset type that we deliver on the web And when compared to the next heaviest asset type of image formats, it's not really even close. Right? Video is huge. So I think it was long overdue that we got better tools to manage this. And in addition to all that waste, there was another related problem. In some browsers, autoplaying videos would start playing immediately when the page loads regardless of whether they're visible and that made autoplay kind of useless on its own.
For videos further down the page, they just start playing and they'd be over by the time you see them. And while autoplay can often be somewhat of an annoyance, it also... It can be used in subtle ways to create a nice experience and I think better tools were needed to do this right. Of course, a video can't autoplay or play at all until it begins to download its video source file.
So our team thought it stood to reason that the feature should... A a well designed lazy loading feature should smartly delay autoplay until a video is visible as well so they could work together. So our hack team set out to better understand these problems, learn about potential hurdles, and, maybe move things closer to a standard solution.
From a design perspective, our plan was to simply reuse the attribute that everyone already knows for images and iframes. Why invent a new thing? There's already a tool that describes this behavior and the web platform actually has a great page, a document about its design principles that includes this sort of pattern of reuse. This is one of its principles.
Reuse HTML attribute names for similar functionality. I'm gonna repeat a few of those principles throughout the talk because they really come in handy as you're working on standards proposals. So proposing such a change to web standards meant familiar... Familiarizing our team with the process.
Right? How platform tests are written, how we want to hack into the browser code and and get to work a little bit. It had been a while since anyone on our team had worked in c plus plus which is pretty common in the browser world but they were pleasantly surprised to find how much they remembered from their school days and unpleasantly surprised to learn how long it takes to build Chromium which is like a day.
But by the end of the week, we had a lot to show. We had drafted an early HTML spec proposal, change proposal, written some tests, even had working prototypes in Firefox and WebKit. Chromium's build was still running, unfortunately. The excitement around the project was enough to convince management to give us more time to see this through and see if we could build lazy loading for video into the foundation of the web and help our own products as well, which could use them.
So the work involved in shipping a new browser feature takes time, which makes sense because standards are meant to be permanent. Right? So if you're coming from a product world where phrases like perfect is the enemy of good and ship early ship often are the guiding ethos, you might find this work to be slow. But you should take to heart that the outcome of all this rigor is indeed a beautiful thing.
In web standards, breaking changes are meant to be avoided. In fact, there's another design principle about that. Prioritize compatibility when changing or removing features. In standards, there's supposed to be no undo button. Right? Supposed to be anyway. I'll take a quick tangent to, talk about one relevant exception.
Funny enough, my own first engagement with web standards was actually a redo. In the original HTML five spec, the video element source elements had media attributes. These allowed us to deliver responsive video and provided a nice declarative option alternative to video streaming. Nice for static files, you can do art directed crops, all the things you do with a picture element.
Right? And of course, performance, smaller videos for smaller screens, things like that. Sadly, in 2014, the media attribute on video sources was removed from the HTML spec. Some folks thought that streaming video was the better choice to sort of nudge authors in that direction and as a result, the spec changed, Chrome and Firefox removed their support from their browsers that had already supported it. And this bothered me a little bit.
Maybe the feature wasn't that widely used but I actually used it. I wanted to be able to deliver responsive videos similarly to how I served art directed images with the picture element which worked great and ironically, picture was designed based on how video works. So that was kind of funny that it got removed after the fact. So I did what most web developers would do in 2020 and I got on Twitter and complained about it.
Rest in peace. And I wrote a blog post on Filament Group's blog where I was working at the time and I filed an issue against the spec and again, got the thumbs up from from some colleagues. That was nice but, the issue kinda went... The thread went quiet for a couple of years. But then one day out of the blue, Simon Peters from, Mozilla chimed in on the issue to say, I agree the change makes sense to revive and there's likely vendor agreement.
And Anna Van Kustrin from WebKit added a plus one as well and soon after that, Simon had PR ed a spec change and merged it and suddenly responsive video was a HTML standard again. But just because something's a standard doesn't mean it actually works in any browsers or it's in their... On their radar to support it.
So even though standard seek vendor agreement, they're often, you know, formalized independently of implementation which of course is why we have a backlog of standards that aren't yet baseline. Right? It seemed to me that our standard could sit unrealized on one of those backlogs for some time.
So I thought maybe I'd try to do something about it. And the reason I had this idea was I took some inspiration from friends. In this case, Matt Marquis who worked with me at Filament Group and Joav Weiss who's here. He's amazing. I don't know where he is but hey, Joav. They, they led the charge to spec and implement responsive images about a decade ago and, got it into browsers and it was really inspiring. I worked a little on...
Alongside them doing a little polyfill work. It's very cool to see. So I decided once again to take a peek into what was involved to make such a change for responsive video in the browser myself. So I chose to work on Firefox most... Mostly I think because it was fast to download and build. It really is. Now I'd like to say this is when I magically conjured an ability to author browser features using programming languages that I barely used before. It really wasn't like that.
Honestly, I got pretty lucky. Firefox's original responsive video code was still there in Mozilla's source code history. So for me, reinstating that code in Firefox was a little more work than like cherry picking a commit and fixing some merge conflicts. I brought back the relevant code, pointed to some new functions and classes here and there and rebuilt Firefox over and over until it got happy. And suddenly, the old, expected failure tests for responsive video started passing. Right?
So it worked And I submitted a patch to Mozilla and Paul Adono at at Mozilla graciously helped me land it in Firefox. I really wanna emphasize how welcoming and encouraging Paul was in this process. It really... It made an impression on me. They're very good with first time contributors and happy to help you along the way if you give it a shot.
Chrome followed soon after that with a fix and Safari actually never deleted its support so we were cross browser again pretty quickly. So that's why responsive video works today and this is an example of it. I'm using two sources to reference the same video on a day out in the ocean, one of the most fun days I can remember recently.
The source videos are cropped to portrait and landscape in this case and it's pretty simple, you know. It's a nice alternative if you just want a simple way to deliver two crops of a video. Rather picturesque, I think. Sorry about that. Anyway, that was a little tangent about responsive video but that experience of being able to advocate for a change and then see it actually happen in browsers lit a little fire for me. It gave me some maybe unearned confidence to try this sort of thing again someday which brings me back to our hack teams project which was to add loading equals lazy using the tools that developers already knew. And in the end, we succeeded in this project.
So I wanna kind of give you some of the the behind the scenes look at, what it took, the steps that it took to get there, because I think it's all accessible and repeatable for anyone who wants to get involved. So standards work is multifaceted, with many steps that need to be proposed and revised in coordination with one another.
There are of course many standards in web standards and the processes are gonna be a little different for each one. I'm only covering HTML today which has its own contributing, you know, list of criteria. But ultimately, you know, if a change involves HTML language features and you want it to work in more than one browser, which is what standards are for, then you're gonna have to propose a change to the HTML spec.
And that involves many steps and associated artifacts to move through the the working groups stages. Early on, I have found the order of these steps can be somewhat unimportant when you're sort of exploring. A spec change is ultimately going to be the source of truth but sometimes it helps to prototype or experiment with the feature first.
You're welcome to submit a a patch to browser vendors before you have a standard proposal or a spec to refer to. It's sort of early early times where you can experiment. Alternatively, some people prefer to channel their test driven development side and write tests first, which can be a great way to explore the the potential and and the details too.
So being new to the process, our team just decided to work a little bit on all the facets at once and it helped inform each other's efforts. That said, a good starting point for any exploration is to file an issue in the in the tracker. That issue will serve as a good place for discussion moving forward. If the work is large enough, the code owners of the repository might ask you for an explainer document.
They might even ask you to break off into a community group effort like responsive images did. But most immediately when you file an issue, you're likely to see it get triaged with labels. You might hear from people like Noam Rosenthal and Simon and Anna with thoughtful feedback and questions. These folks really know their stuff.
You can expect feedback to be really thoughtful, informed and I think conservative, you know. This is important stuff to get right. Once an idea has worked through enough, you can propose an actual change to the standard by sending a pull request to the same repository. So this is all like running on the tools that we use every day. And once you do, it'll helpfully surface a checklist of additional things you'll wanna do.
And these are things like a clear commit message, which they give you an example of, seeking the approval of browser vendors, ideally three of them. You need platform tests, you need to file bugs in each browser's tracker to implement your feature, asking nicely. Also, corresponding accessibility standard, issues should be filed if that's relevant.
And lastly, if you're lucky, filing an issue to request documentation on MDN. Let's look at some of those. So first, web platform tests. These are HTML files that browsers... All browsers run the same suite of web platform tests to verify that their features work according to spec. It's very cool. If you're new to them, I think they're really approachable and it's a great way to get involved in web standards to write tests. For example, if you find a browser bug, writing a test against it is a great way to draw attention to it. You'll need to write fresh tests to support a new feature if that's what you're proposing and our team ended up contributing over 30 of those at first.
I think there are more now. It sort of evolves as, you know, you you run into more use cases with the feature. And if you're writing tests against tentative features that are not yet standard, they have a process for that too so you can land the test first and then the spec can follow. It's all very well thought out.
Then you'll need to find a formal approval from browser vendors and get their standards positions. Mozilla and WebKit actually have dedicated issue trackers for this where you can request a position on your on your issue. You file an issue, they decide on it, give it a positive or negative over time and then close it. In our case, Simon from Mozilla and Anna from Webkit handled both of these. On the other hand, Chromium is a little more casual I've found. They tend to like, you know, comment on the issue itself with their position.
Dale Curtis, who's the engineering lead for media playback at Chromium, gave an approval on Chromium's behalf for our proposal. So all community efforts here. And then there's the spec writing which I'll admit is its own skill and one that I claim no, you know, no expertise in. But I have found that it's learnable and it gets easier, with the more time that you spend with it.
And before long, you'll develop strong and socially offensive opinions about when to use words like must and and may and should. When your spouse asks where the entire bag of cookies went, maybe instead of saying, you know, I'm going to be candid with you, you might say, this section is about to be non normative.
Anyone can learn to make helpful contributions to the spec. The repo itself has good first issues, where you can open a PR, fix a typo, and you're a contributor. So I'd suggest doing that. If you make it to the late stages of ratifying a standard, you will need to ask for documentation in MDN as I'd mentioned.
You do that in GitHub as well and that means you get to collaborate with folks in developer relations to... Who who help developers understand how how these standards work. And in our case, we got to work with Barry Pollard, hey, Barry, from the Chrome team to write the the documentation for loading equals lazy for video.
So thank you, Barry. One of the best parts of the process of contributing to standards is the process itself. Right? So if you're planning a a feature or a change, you're gonna spend a lot of time thinking through ideas, debating ideas, going back to the drawing board on things. There are stages that you work through, zero through four and biweekly meetings where you can actually go and and talk to the working group members and get feedback.
And a lot of the time is spent there and sometimes the feedback process reveals big design problems where you'll need to go back to the drawing board. For example, pretty far along into our implementation and and, spec work on loading equals lazy for video, Ali Pate from, Mozilla added a comment to our proposal and said, what about the audio element?
Ali was rightly wondering why loading should be defined on video when video and audio both run on the same kind of base prototype or or class called HTML media element. And that's not an element you can use in the browser but they both run on it and a lot of their attributes are are defined in that central place.
So Ollie was wondering, why not audio? This could work there too. And Ollie was right. So it was a relatively big change but after some discussion, it was clear to all of us it was the correct one and we went back and changed the spec and the implementations and the tests and the tickets and all of that to include audio as well as video. So that's why it works in both today.
And that that same feedback rippled through the implementation code reviews as well which we were working on. So if you work on Firefox implement... Implementation, you'll be in the fabricator tool at Mozilla. I wanna call out one person in particular that we worked with at Mozilla who was just instrumental in championing our our work on this on this standard and helping it move along and that's Keith Circle. Thanks so much, Keith.
It was it was really really nice to have you helping us along the way. As for WebKit, Squarespace's Credo Duarte, one of my colleagues, wrote our WebKit implementation and that happened in the the WebKit tracker on GitHub and emerged as you can see. So we should see it in in Safari in the future.
And then there's Chromium. Our team didn't write a Chromium implementation but we were very lucky to get a contribution from a member of the community and this is where I need to give a shout out to Helmut Januszka. Helmut is a wildly prolific independent software engineer who has contributed a number of browser features and he excitedly jumped in and helped us with the implementation on this.
So it's fantastic. I'll mention Helmuth again. So in March of this year, the boxes were checked and the group voted to move our proposal to stage four which meant HTML video and audio lazy loading became an official web standard. So that's what it is now. It's in HTML, and you can use it today.
It's in... Thank you. Chrome and Edge have had it for a couple of months now. It's in Firefox one sixty behind a flag, so hopefully, a future release will enable it by default. And Safari, it's merged into their main their main code base, so we'll see it in an upcoming release.
It's very exciting. So let's look at how we can use it because there's some nuance to be aware of compared to to images, lazy loading. So to start, loading equals lazy, same tool that you already know and that'll cause cause it to defer the audio or video elements behavior until it's visible. Keep in mind when I say deferring the behavior, it really defers all of it. If your video has a poster image, its request will defer until it's visible.
Other things too, other attributes, preload, a little confusingly named attribute but preload allows you to say, I want to load none or just the metadata or all or some of a video, upfront before it's played. No matter what the value is, it still works and it coordinates with, loading equals lazy.
It just sort of applies after the deferred behavior, once it becomes visible. Autoplay as well will defer until the video is close to the viewport so you can rely on it for playing a video when it's close to visible and preloading will be deferred for poster images if loading equals lazy is there, just like images.
So let's see some demos. So this is in Chrome, stable today. Here's a demo page with some lazy videos just in a long list. I call it sloth cast, a video podcast homepage example. In dev tools, on the right, we have requests and several of them, several of the videos already requested and as I scroll through the page, they fetch, as they near the viewport.
So we can see that happening once I start scrolling. And I wanna clarify, I'm not implying sloths are lazy. They're actually specialized to conserve their energy until it's most needed, so an ideal mascot. Let's try lazy autoplay.
I made a little marketing page to scroll through with some videos and pictures that I took while I was being a cheese tourist all week. The top video background is an eager regular video, loads eagerly because it's in that top of the viewport area and then further down, images and videos load lazily using loading equals lazy.
The last one is autoplaying so it only autoplays when it scrolls into into the viewport. Since laziness is shared for all media, lazy audio elements are a thing too. Let's say you have a podcast or a music player website with lots of audio elements, they can now load lazily as you get into the viewport.
Side note, if you want to lazy load audio, it has to be visible because it has to intersect with the viewport so you can't have a hidden audio player and load lazily. Many of the best practices for images lazy loading are the same for video. So there was a lot of writing about making sure you don't lazy load your your LCP image.
Same for video because a video and a poster can be the LCP element. So bringing it back to Squarespace for a moment, it was neat for our team to see this work come full circle back to our own product. This is in the CMS and our customers can use lazy loading on their on their videos to to choose eager or lazy on their own or just let the CMS pick a a best guess.
So that was, media lazy loading. I wanna talk about another standard that's, in the process now. It may be something we can use in the coming year. We had another hackathon in the spring, so we set out to to solve another video problem. This time, we set our sights on improving how video poster images work, which is something Squarespace could certainly use.
But more broadly, I think it's something that has needed an upgrade for quite some time. So my coworker, Alexandra Moskowitz, teamed up with me to help plan and strategize on this project and she wrote the platform tests as well. Let's talk a little bit about posters. They're everywhere on the web. Despite their commonality, you might be surprised to realize how underpowered they are. For the last twenty years, they're just this single attribute.
Right? They point to one image and they have no ability to negotiate different sizes of an image or different, you know, crops, art direction and there's no way to describe them with alt text. Right? So very underpowered and I think that's pretty problematic on the web today considering how posters are used.
Right? The spec defines them as a still frame representative from the video but in practice, they're not used that way. They're more like a cover, like a d v d cover or something, for the video complete with burned in text and a creator making an incredulous face, because even they can't believe what their poster is claiming that it's going to do.
So, they carry a lot of meaning and that's gone undiscovered for too long I think. So we started to look at this design and first we had to debate, how it would be built. One decent option, was to add attributes to existing source elements in video to mimic what an image does. Right? Like poster source set, poster sizes, poster alt.
Another option, was to allow a child image element inside the video to control the the parent's poster image. In the issue thread, a healthy debate ensued, and ultimately, we all decided on the second approach for a couple reasons. One, it's forward looking. Image has features that work now and will gain features in the future and poster can take advantage of those.
It also satisfied a principle, build complex types by composing simpler types. There was a problem with the image design though. Video has long allowed fallback content for browsers that don't understand HTML video and unfortunately, as the archive search confirmed, lots of video fallback content on the web contains images that say, sorry your browser doesn't support video. So that would mean posters like...
Or images like this could get elevated to a poster which you couldn't pick a worse image to use as a as a video poster. So we needed an opt in, for authors to to do this, with with purpose. So we debated some, some options and one was to use an empty poster attribute and this would work but it had a downside that it breaks backwards compatibility for the poster attribute.
And ideally, we wanted to keep the poster attribute usable for browsers that don't understand poster yet. A second option was a boolean attribute to signal intent and that was fine but it's a little disconnected from what you're doing inside, the video with with an image. We tried poster from image. Katie Seiler Miller, had a better idea of, has poster image, kinda described it a little better, same utility.
A third option, a new element, poster. This would work similarly to the, to the to the boolean attributes but it's a little more self documenting, I think. Ultimately, went with the new element, so far in this proposal and the design principle here, prioritize compatibility when when, changing features.
So keep that that poster attribute. So we submitted a proposal this spring and it's been moving along well. It's at stage two. There's actually a meeting today where we're going to talk about maybe moving to stage three. So it's very far along, many months in, and it already has positive, standards positions from Mozilla and Chromium and a working Chromium prototype, web platform tests. So it's really coming along.
So again, this is a process talk. This is in progress. It could change. And if you don't like it, you could go in and help us change it. But let's look at how it might look per the proposal. So this is an actual example of from the HTML spec proposal and as you can see, a poster element wraps an image.
It's a regular image, supports our set, alt, sizes, auto, things like that. When a poster element is present, it takes precedent. So supporting browsers will see that and ignore the poster attribute if it's there. So that becomes a fallback. The poster attribute, still handy. I would recommend if this becomes standard that you keep using it for a while because that's how we'll deliver posters when we want to to browsers that exist today.
Since the poster could now come from multiple places, there's a new property, current poster. It's kinda like current source on image. This one tells you what the current poster image is. So that'll just negotiate regardless of where it came from. Let's see it in action. This is a working Chromium prototype again from Helmut.
So thanks to thanks to the the work on that. It's been awesome. So here it is. I'll I'll hit play. This one is with source set, driving the poster attribute for higher and lows... Lower poster images and I've made images that just have the dimensions burned in so you can see that it's changing like you'd expect source set to do.
So that uses source set which of course is a suggestion, to the browser. On the other hand, the picture element is the opposite. Right? It it uses media queries. It's more like instructions to the browser that it's supposed to listen to. So the poster element, proposal allows a picture to be inside it too. You can wrap the image with a picture and then you get art directed, breakpoints that match the breakpoints of a responsive video. So lots of these little composable pieces are are all able to work together. In this example, I'm pairing poster images in landscape and portrait to to a video of the same the same two aspect ratios. So here's a demo of that running with picture in the Chromium prototype. Yeah.
There we go. And it's subtle but it is actually loading two different images here, crops to portrait or landscape and I can confirm that over in dev tools by selecting the video, getting current poster, and seeing that indeed the source is is switching. So tying it back to lazy loading, the poster element continues to play nicely with that.
So it'll inherit it actually from the video element if it's defined there and it can also be set on the image itself if you just wanna override it or control it at the image level. I think the the common behavior would be to just put it on the video where it already where it already lives in the standard.
This is a performance conference. Right? Image elements support fetch priority so that works in poster now. Right? If if poster proceeds to to standardize in this direction. That means, you know, poster images that are your LCP, you can make them fetch at a high priority. And that's good because video can be your your LCP element.
Previously, it was pretty hard to do this. You had to, you know, use a preload link and you didn't have the responsive images. It's it's tricky. So this should help. It also supports other image features. Anything that image does for the most part. So decoding equals async. Fun fact, only a few people in the world understand when to use image decoding equals async.
Both of them are in this room. I'm not one of them. But if you wanna do that sort of thing, you can. The part I'm most excited about with this proposal is that for the first time, the poster element, will mean that poster images can be perceived by assistive technology. So since it's an image, naturally, it has an alt attribute and in the spec proposal, are some guidelines for how to use it in this context because it's a little different.
I'll I'll show I'll show what that... What I mean by that. Essentially, want to describe the the frame, not the film. So this example is actually from the spec proposal in the image alt guidelines section and what I like about this example is I think it makes a pretty strong case for using a poster element just for the alt attribute alone.
Even if you only have one image and you're not trying to negotiate different different poster images, now you can make it accessible. So let's see how it works in the Chrome prototype again. I've enabled voice over browsing this page. Let's hear poster speak.
HTML poster element. Heading level one, responsive, accessible video posters, a demo that coordinates portrait and landscape formats of video and poster sources by using a poster element with a picture. In supporting browsers, the child IMG elements alt text describes the video poster when it is visible. A surfer standing up on an unbroken wave, smiling at the camera.
Video preview. You are currently on a video preview.
Okay. So to recap, we just heard a poster image. Speak aloud. We so far are suggesting that it be exposed in the accessibility tree only when it's displayed so that it's the same experience for everyone because sometimes poster goes away when the video starts playing. Right? Also, we think it needs a little extra context.
So you probably heard this is a video preview. That's a role description. So we we suggested adding that to to kinda give context. It's not just any image. So one last thing I wanted to cover was to come back to responsive video because when we resurrected it to its original state, I think it still kind of fell short of where it needed to be. It's responsive, but unlike picture, it's only that way at initial load. If you resize the window or change your orientation, media queries don't update the video source to change it.
And I think developers find that a little awkward when they're used to working with picture. Particularly now as poster element could potentially make video feel pretty responsive. I think it would be nice if this matches up. So in the spirit of sharing process, this one's a lot earlier than poster, but I've been musing on it. This ticket suggests that we consider rerunning the same source selection algorithm after page load, so for video and audio.
So basically make it responsive with cropping and art direction, which I think if someone goes to the length of putting many sources in a video with different crops, it's probably what they'd expect. So again, it would look like this and you would see a change after page load on resize and things like that.
So quick demo of that. I made a polyfill just in JavaScript to see how it would work, and this means it syncs the time code as well if the video happened to start playing already. So first, we have the poster and then if I hit play and resize, it'll swap sources and carry on in a wide format.
If And you're designing a layout around expecting different different aspect ratios and stuff, that should be nice. Thanks. If you remember back to the start, audio is... You know, it shares that base class, and audio was always responsive too, which is kind of funny.
We don't really think of responsive audio. I'm honestly not sure there are many good use cases for it. I came up with one. This is like a dashboard that has an audio guide that describes the layout, depending on what you're seeing on the screen, and it needs to describe it differently.
The navigation runs down the left edge of the screen. Use it to jump between overview, features, browsers,
and the points.... The breakpoint. So...
Across the top.
Here, it's describing the left navigation.... The
crawl.
This is not a screen reader. This is
like a Tie.
App feature. Right?
The summary card sits on a small screen. The navigation is tucked behind the menu button at the top left.
Okay. So now it's describing a a mobile layout. So maybe can try
Tap the filters
could be a use case Just
under the header.
To set your fun table
one. Crawl.
In this demo, I've added an audio element referencing a person singing a note, and I've encoded it at higher and lower lower semitones as well, using responsive audio sources to reference them all. And you guessed it, media query breakpoints every 20 pixels. Let's resize that baby and see what happens.
I have invented the world's dumbest trombone. Alright. So to wrap up, on the web, our medium can be changed by any of us willing to get involved. As performance engineers, our dashboards know things. Right? We see patterns that slow down our metrics and we know when we're shipping the same code over and over and there's an opportunity to move something into the browser.
So file an issue, hack on a local browser, experiment with it, get folks behind your ideas. There's a web standard principle for that too. Leave the web better, than you found it. This room has a lot of people who do that all the time. Yoav, I mentioned Yoav is one of them. And when he finished up on responsive images, he gave a talk about it and he said this, my takeaway from the effort is that the web is ours.
If we wait around for other people to fix the stuff that we think is broken, we're gonna wait around for a long time. It's our job to work with the browser vendors to make, make it work the way it should. I think that's really nice. I've long been a consumer of web standards but it took me too long to jump to being a contributor and I regret that a little bit. I think we're all suited to be involved.
So our work is changing. Our tools are changing. It's a little scary, but as Yoav said, the web is ours. As performance engineers, we should look to spot the patterns, that we could build into the browser and trust that we can do that work ourselves. Your sites will get faster as a result and ours will too. Thanks.
People
- John Resig
- Keith Cirkel
- Simon Pieters
- Anne van Kesteren
- Mat Marquis
- Yoav Weiss
- Noam Rosenthal
- Dale Curtis
- Barry Pollard
- Helmut Januschka
- Alexandra Moskowitz
Technologies & Tools
- jQuery
- querySelectorAll()
- Autoplay
- C++
- Chromium
- WebKit
- Web Platform Tests
- HTMLMediaElement
- currentPoster
- VoiceOver
Standards & Specs
- HTML Standard
- <picture>
- <poster>
- fetchpriority
Concepts & Methods
- Responsive images
- Native lazy loading
- Responsive video
- Baseline
- Largest Contentful Paint
Organisations & Products
- Squarespace
- HTTP Archive
- Firefox
- Chrome
- Filament Group
- Mozilla
- GitHub
Works
- What the Spec
- Web Platform Design Principles
- MDN Web Docs











