447 points | 11d ago | Discuss on Hacker News | Back to Radar
This is exactly what I need when I need it. The amount of pull requests I reviewed with a mess of codes that can be switched to 2 lines of modern features made me write such tools myself, only half assed since I have other things to do.
But I'd not inject all this fluff into the wheels of the machine because it'd just take the "average" of these practices which would be just as useless.
That index page should link to plain markdown versions of all of the documents, and should be designed for search with grep to find the right answers.
That way I don't have to install anything at all - provided my agent has the ability to make HTTP requests I can tell it "Look for tips on https://googlechrome.github.io/modern-web-guidance-src/skill..." and it will fetch the index, then navigate to the most relevant documents - no MCP or npm or installation required at all.
(we could make this clearer though)
We'll make this happen. :)
It feels that something like this would be the holy grail of agents. A small agent that has only the minimum necessary built in knowledge. The rest, it just retrieves on the fly when it needs (+ caching)
It’s like storing pointers/links instead of the contents
But yeah.. big corpus of valuable context × minimal agent footprint = happy place.
Also Mozilla only joined in the last few weeks, so they haven't yet had a big influence on the project (though I expect they will going forward).
[1] https://github.com/GoogleChrome/modern-web-guidance-src/blob...
https://github.com/GoogleChrome/modern-web-guidance-src/blob...
There's a plugin for Antigravity that's listed on initial setup (yay bundleware! :) but... yeah if you're using consumer gemini, i'd switch to the Tasks mode because it's more agentic nature helps.
In fact I just did this and it works. :p It regular Gemini, it said it did but kinda liked :) So there it'd be
> Create a perfect HTML contact form with address fields. Check https://developer.chrome.com/docs/modern-web-guidance/guides... — read completely, don't stop at truncation.
In short: I 100% understand your disappointment. :) More coming soon like finding cases to update with Promise.withResolvers, the Array iterators, Object.groupBy, URLSearchParams, etc..
Of course, it's not perfectly implemented the same in every browser, but that's nothing new.
The more "legacy code" is getting written everyday the more the web will be forced to remain backwards compatible...
On the other hand, a bit sad: programming nowadays is just arranging a bunch of Markdown files, possibly generated by another bunch of models.
Not so exciting, in the end.
And now this just fell in my lap! Some of the arguments I wanted to make seem to be provide here. Didn't have a chance to take a proper look at it, but it looks very promising and nice!
Thank you!
CSS @function
CSS calc-size()
CSS interpolate-size
CSS corner-shape
CSS border-shape
CSS flex-wrap: balance
CSS text-fit
CSS text-decoration-skip-spaces
CSS scroll-axis-lock
CSS scroll-target-group
CSS :target-current
CSS scroll-initial-target
CSS container scroll-state queries
scrollsnapchange event
scrollsnapchanging event
HTML focusgroup
Element.startViewTransition()
CSS view-transition-scope
Interest Invokers (interestfor)
LanguageModel (Prompt API)
LanguageDetector
Translator
Summarizer API
Window.fetchLater()
Speculation Rules API
Long Animation Frames API
VisibilityStateEntry
PerformanceSoftNavigation
InteractionContentfulPaint
Connection-Allowlist
CSS url() integrity() modifier
HTML meta name="text-scale"
HTML template for
HTML processing instructions
PasswordCredential
Promise-returning scroll methods
Web App Origin Migration
Local Network Access permissions
Request.targetAddressSpace
beforeinstallprompt event
To be fair, the skills also recommend ~11 features not supported by Chrome itself. And the project does seem concerned with compatibility: "Guiding models to use sensible, lightweight fallbacks."To be clear, the skills document how to use these features to solve common use cases, and then they give your agent a full browser support table for any APIs mentioned that are not Baseline Widely available -- and then your agent can decide whether to use them or not, based on your site's browser support requirements.
In most of these cases a cross-browser fallback is also documented.
"DO use fetchLater()..."
"Your own code MUST call fetchLater() directly..."
https://github.com/GoogleChrome/modern-web-guidance/blob/mai...
But yes, the skills do document compatibility and fallbacks well.
The mental model we've been using on the team is:
If you hired an expert web development consultant to build X, what would they recommend as a best practice? When does it make sense to use the new API (because it provides real benefits) vs. when does it make sense to wait until it's available everywhere?
To use your `fetchLater()` example, this is a case where the `fetchLater()` API legitimately solves a very real problem for people trying to build accurate analytics or telemetry features, see: https://nicj.net/beaconing-in-practice/
And lots of companies actually are already using `fetchLater()` in production now because of its increased reliability.
Regarding corporate incentives: I was involved in the design of this API, so I know the history. It was proposed many years ago as a solution to make it easier for RUM analytics providers to measure Core Web Vitals metrics that needed to account for more than just page load (e.g. layout shifts and slow interactions can happen any time, not just during page load).
The RUM providers we worked with were reluctant to wait until page unload to send telemetry data because it resulted in too many lost beacons, so what they do instead is send beacons every few seconds with the most up-to-date payload.
The `fetchLater()` API enables them to send just one beacon, which is good for users and also reduces their server load.
It's a bit sad that browsers now have two different, "standard" APIs created entirely for the purpose of user tracking, as if things weren't already bloated enough.
I’m really glad to see this not evolve into a flame war as well.
In the case of fetchLater, judging by https://nicj.net/beaconing-in-practice-fetchlater/ (which I think you intended to link actually) since I haven't come across it before, it could be implemented with fetchLater, events and a timeout, perhaps 10 LOC or so? If that's the case, then it almost never makes sense to use Chrome's own fetchLater, rather than those ~10 LOC so it's actually web-friendly instead of just Chrome friendly.
As a side-note, I'm getting increasingly wary about all the new JS APIs that seemingly gets added to our standards ONLY because they have ads/tracking interests. Used to be the people who participated in standards discussions for their ads/tracking interests came up with proper use cases and kept quiet about their erosion of privacy, but seems the mask is fully off today and we're just making browser engines for the ads companies now, yay.
This would be deeply surprising to me, and I am the target audience for this repo. I'd expect the default here to be Widely Available only with some opt-in for the courageous. I don't know that I'd even enable it.
[0] https://github.com/GoogleChrome/modern-web-guidance/blob/4dd...
You have causality reversed here. If you need to detect if the page was loaded in the foreground or background, it is nuanced and (relatively) complex. Therefore it's good for your agent not to just assume document.visibilityState is all it needs to check, or you're going to be getting seemingly impossible log entries pretty quickly.
You're making this into a false binary which is wrong (the alternative to adopting Limited Availability features is not "document.visibilityState is all it needs to check"). But responding to my one example is also going to cause us to miss the point I'm making entirely.
If you scan to the bottom of the guide under the "Fallback strategies" section, you can see the recommendations for how to deal with the aspects of details/summary that aren't Baseline widely available (e.g. mutually exclusive details).
That's fine though. Progressive enhancement, adding features to a site when they're available but still offering a working site when they're not, is how we should build web sites. That way they work for the user's device rather than the developer's opinion of what the web should do.
Working that way completely removes the decision about whether or not to use a feature because it doesn't work for some people, and moves it to a decision about whether or not it's worth adding for the users on browsers that can use it. In the past that was a real development effort cost, but today where AI writes the code the effort is much, much lower.
If you're using AI to make something but still using heuristics designed to save coding time then you really need to rethink your mental model of how to decide what gets built.
Websites created today should all use server-loaded content for the first render, small page sizes, a sub-1s loading time, progress enhancement for features, and WCAG 3.1 AAA accessibility (maybe.. at least AA though) because doing that isn't any more effort than not doing it.
Alright, that's fine and dandy. Is this the actual results of using this skill though that is being advertised here? Is it asking the agent to also make sure it's "Progressive enhancement" so the same stuff more or less works in Firefox and Safari?
If not, your whole point is kind of moot, as you have someone from Google trying to get people to write websites that'll look and/or work differently in Chrome compared to other browsers.
Unless you have specified something different, by default the skill assumes you are targeting Baseline Widely Available, which means everything has to work in all major browsers from at least 2.5 years ago.
These concepts are new, so no one knows if they are any good. They're not modern -- who knows if they will even be put to use?
"contemporary", "proposed", "suggested", "compatible" are better fit. I wouldn't dare use "advanced" because many APIs and proposals actually regress earlier behavior.
Came up with a good list for my project
Keep your effing websites simple.
(I have much the same instinct about the UNIX philosophy. Bash is not too big. Shell programs should be even bigger so that query programs can be smaller — because otherwise they grow huge lists of options that largely overlap, for things like table formatting, and provide an inconsistent UX.)
Good god.
We built rigorous tests to verify this actually works, and to know when models no longer need the advice.
> prohibiting the spread of React (and other frameworkist totems) by policy is an incredible cost savings and a helpful way to reorient teams towards delivery for users
isn't "simple".
But how? Hopefully filing an issue on the modern-web-guidance-src repo is the right place? Anyway I filed one for using fromBase64 and toBase64 instead of atob and btoa.
But since you're all in on agents anyway you should consider having one look through at least all of the JS, DOM, and HTML spec commits in the last 3-5 years and automatically triaging any that are clear improvements and are not used by agents. Would be pretty straightforward.
---
Btw, I think it would be very helpful to automatically provide versions of this depending on what browsers you're targeting. I don't want to use anything that hasn't been available in all evergreen browsers for at least a year, for example; I think most developers have a similar standard, or at the very least don't want to use the bleeding edge. And while it is _possible_ to get that from your repo, it takes some effort, either writing a script or letting the agent use its own judgement for every feature. That's work you could do on your end and save the rest of us from needing to.
> Btw, I think it would be very helpful to automatically provide versions of this depending on what browsers you're targeting.
This should work today (though not exactly in the way you describe). The skill tells the agent how to interpret guides based on browser support signals it gets from context (e.g. the prompt itself, or AGENTS.md).
You can see those instructions here: https://github.com/GoogleChrome/modern-web-guidance-src/blob...
Right, my point is that I don't want to spend a bunch of time and tokens loading the skills and having the agent reason through whether they apply based on browser support. I want that to be automated so that it only loads in the first place those things that are actually applicable. Having a prose description is not a substitute for automation; it is almost always better to do things mechanically rather than asking the agent to do it, in cases where it is possible to do mechanically.
I think this matters even if you're at Google and tokens are free but it _definitely_ matters for the rest of us.
Most sites are willing to use some features as a progressive enhancement, whereas other features they won't even consider using unless it's in 99+% of their users' browsers.
And unfortunately there's no easy way to make that decision for users on a feature-by-feature basis, because it all depends on what use case they're trying to accomplish, and what will happen if the feature is not available (given that particular use case).
So our approach is to (1) explain in the guide how to implement the use case with the modern feature, (2) explain why the modern feature is the preferred solution (e.g. what the user benefit is), and then (3) explain how to implement a fallback solution if the feature is not available.
I think we could potentially experiment with some version of what you're describing, like a config option where we only surface guides that have robust, widely-available fallbacks, and where we have high confidence that it makes sense for the majority of sites to be following the recommendations in the guide.
I'll raise it with the team.
My experience differs from yours. It's true that there is some tiny fraction of features where it makes sense to do progressive enhancement, but for most sites and almost all features this does not make sense: the burden of testing and maintaining a site that effectively has multiple versions depending on what browser you're using is simply not worth it. For typical dev teams outside of Google/Meta/similar, the right thing (and the overwhelmingly common thing) is to target the intersection of features available on your supported browsers and not make any behavior conditional. I'm not interested in any guides that need fallbacks on any of the browsers I target and I expect the same is true of the typical dev team outside Google.
Like HtmlFlow (Java/Kotlin) or kotlinx.html.
I pick Tailwind and Alpine.js to go with this approach because: I want to be SSR-first (with small JS-based improvements where they matter most) so NOT and SPA, i want the styling to be close to the HTML code that's being styled (no need to match between CSS definition and usage), and I also prefer to keep my tiny bits of JS close to the HTML it deals with (Alpine makes that easy and provides a clear path for implementing 99% of my JS needs).
Like everyone, LLMs code it for me :) But the result is easy to reason about for myself and my LLM. Little vanilla JS. No jQuery. Mostly just some HTML-bound Alpine instructions. And Tailwind everywhere. This way I can look at one place to see how it works: or CTRL-click my way to it.
Why do people still leave common AI tells in their writing?
I want the browser to be the thinnest layer it can be, between me and my application, which is governed by me.
Of course great resource for all the others who feel they need to just go with vanilla JS.
I'm getting the feeling that the user experience they want is not necessarily what I would term a good one.
Yes, now I can confirm I am not a crackpot when I said this: https://news.ycombinator.com/item?id=49854536
The main problem I see is that it will be extremely hard for new frameworks, languages to take off if everyone is using AI to code. It can lead to a future where all new programming languages and frameworks will be developed by LLM providers because only they, can train them with synthetic data.
With LLMs improving, they will might need less example code to work with new frameworks decently
With LLM usage becoming ubiquitous for coding, framework developers will likely start making lots of curated, high-quality synthetic examples specifically for LLM training data usage as their main documentation effort
I tried to look this up and found https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/S... but the example depends on JS. How are you meant to statically specify highlighted ranges without the <span> markup? If I'm syntax-highlighting code on a blog, it's seems a lot more practical to just use the old <span> system than to encode a list of character ranges in a JS array and loop to assign highlights. Plus it doesn't require the reader to run JS.
Comments are loaded live from Hacker News and are not stored by Mid or Real.
phyzix5761 11d ago on HN
natorion 11d ago on HN
paulirish (author) 11d ago on HN
So I'll take a 1-line CSS solution over 60 lines of ResizeObserver/setTimeout business. But.. best practices for frontend isn't just the code.. it's ensuring quality UX, that keyboard navigability works, that layout doesn't shift on users.
aidos 11d ago on HN
noosphr 11d ago on HN
runeb 11d ago on HN
https://aicoding.leaflet.pub/3majnyfydzs2y/l-quote/10.0_0-10...
noosphr 11d ago on HN
soon_to_be_sb 11d ago on HN
Are you in the business of selling tokens/electricity/gpus by any chance? Then good for you!
But terrible for everyone else....
noosphr 11d ago on HN
brlewis 11d ago on HN
This is a misconception. Have your favorite agent summarize this video for you: https://www.youtube.com/live/zcLPGC-tvgk?si=YR68aHlFESD053bh
ozim 11d ago on HN
But the fun part is that all of the proper software engineering practices are aimed at lowering amount of context a developer has to keep in his mind. So it directly applies to agent context. Less verbose code, less tokens to burn, separation of concerns, lower chance agent breaks something unrelated etc.
vik0 11d ago on HN
>This is a misconception. Have your favorite agent *summarize this video for you*: https://www.youtube.com/live/zcLPGC-tvgk?si=YR68aHlFESD053bh
I can't tell if you're joking here
brlewis 11d ago on HN
drawfloat 11d ago on HN
brlewis 11d ago on HN
zahlman 10d ago on HN
zahlman 10d ago on HN
Sure, I've seen the video before and remember many of the arguments. I don't agree with everything in Bob's approach, but I certainly agree with what he says about the value of looking at the code.
But that doesn't at all mean that people will do it.
sublinear 11d ago on HN
Browser-specific implementation gotchas tend to take about a decade to iron out for reasons that never have anything to do with code quality. Users are fickle and so are browser vendors, but that's a different topic.
At the end of the day, there's just no escaping lots of manual testing across device and browser combinations if your goal is a polished result and not just something that "works".
AI has done nothing to make this problem go away. If anything, it's made it worse because people don't even want to look at the code now!
zeroq 11d ago on HN
I've recently finished a browser game specifically targeting an old iPad Air 1 we had lying around the house.
I had a working version after a weekend, but it took me a month to make it run smoothly on an over 10 years old mobile device. And the most recent browser available is almost 10 years old.
Surprisingly I didn't missed too many "modern" JS features, as these were mostly functional programming oriented which doesn't play well with optimization anyways, and the ES6 was more than enough as a programming platform.
Anyway, what I'm trying to say is that "the best practice" should be making your apps fast and accessible - as much as you can without having to sacrifice something you value - instead of chasing the latest and shiniest.
Don't be a fashion driven developer. :)
jefftk 10d ago on HN
stronglikedan 10d ago on HN