跪拜 Guibai
← Back to the summary

Hands-On: AI Swaps Hand-Rolled Modals for Native <dialog> After Installing Four-Browser Skill Pack

Title: Recently Viral Chrome New Skill Installed into WorkBuddy, AI Coding Takes Off

A no-water Agent Skill field test: modern-web-guidance is not a prompt, it's a textbook that takes "what the browser would do anyway" out of your code. Two engineering points worth watching: first, it doesn't rely on the model's self-awareness, but installs new standards into the skill directory; AI reads the textbook before acting, so before/after code for the same requirement can be diffed side by side; second, it distinguishes two ways of checking - the command that scans for old syntax only reports rules it's confident about, preferring to miss (in the test it reported zero), while switching to checking against the textbook finds lots (nine popups hand-built with overlay masks, fifty-plus behaviors written on tags, thirty-plus innerHTML, and not one Esc). This article reproduces the test in six steps, with 6 complete copyable texts, before/after code comparisons, and the reasoning behind the conclusion that "new syntax is more maintainable not because there's less code".

I'm Xiao Hu, CS bachelor and master from Zhejiang University, Breakthrough Practitioner, author of "AI Super Individual - A Guide to One-Person Company", focused on AI training, super individual development, and efficiency coaching for companies.

Recently on GitHub's trending list there's a project climbing fast: a skill pack led by Google's Chrome team, released only a few days ago, gaining over a thousand stars in a day, now with eighteen thousand stars in the repo. Backing it are the four major browser vendors.

Hello everyone, I'm Xiao Hu.

image

image ▲ The homepage of this project on GitHub, the red circle marks the star count

Why are the four rare to join forces? Because AI used for coding picks up the old syntax from its training data, and one vendor calling out alone isn't enough; the new standards have to be packaged as a textbook and stuffed directly into AI programming tools.

If you've had AI build web pages, you've probably seen code like this: functionality correct, but all syntax is old - popups hand-built with tags for overlay, tooltips positioned by calculating coordinates, and a bunch of officially deprecated syntax used as is. Not that AI is lazy; it's that the textbook it learned from is too old.

These past two days I ran an experiment with this new project: six prompts. Before installing it, I first had AI build a page with a popup; after installing, I had it build the exact same thing again; then I took a real piece of code I use daily and sliced it open to see whether this new textbook actually works.

The protagonist is GoogleChrome/modern-web-guidance: maintained by Chrome, Edge, Firefox and MDN together, containing over two hundred modern web features and over two hundred standard patterns for real-world scenarios, intended as a textbook for AI programming assistants.

Step 1 Before installing, have AI do a bare version

I threw the requirement over exactly as is:

Help me make a small web tool: a page reminding me to drink water. The page has a button; click it and a reminder popup appears. When the popup appears, the background should gradually darken and get a bit blurry. Make it look nice, then open it directly for me to see.

The page came out quickly, a single file, double-click to open: when the popup appears, the background gradually darkens and blurs, with a slight rise animation. The right side opened the page directly.

image ▲ The first version of the water reminder page AI made before installing the skill

Looks like the real thing. Keep this version as the control group.

Step 2 Install the skill

There's a recently hot project on GitHub called modern-web-guidance, supposedly made by the four major browser vendors together, specifically to fix AI writing front-end code with old habits. Install it, then tell me what it can do after installation and how to use it.

It installed over two hundred files into WorkBuddy's skill directory, then told me three uses: search guides for a topic, get the full guide, and scan a project for old syntax. After installing, it even took a slice at the water page from earlier and actually caught things.

image ▲ AI's reply after the skill was installed, and it tried the first version on the spot

Step 3 Do the same popup again

Make that water reminder popup again, same requirements, but this time use the skill you just installed. Open it when done and show me, then tell me what's different from last time.

This time it read the textbook before acting, and after finishing it did a review of both versions: three old patterns in the before version, zero after installation.

image ▲ AI's own review after making the second version

No difference in appearance, all difference in code. I copied the key code from both versions side by side. First the opening of the popup, the old version:

<div class="overlay" id="overlay">  <div class="card">    <h2>💧 该喝水啦</h2>    <button onclick="closeOverlay()">好的,马上喝</button>  </div></div>
function openWater(){ overlay.classList.add("show"); }function closeWater(){ overlay.classList.remove("show"); }document.addEventListener("keydown", e => {  if (e.key === "Escape") closeWater();});overlay.addEventListener("click", e => {  if (e.target === overlay) closeWater();});

The new version switches to the native popup tag, and the JS is only one line:

<dialog id="waterDlg">  <h2>💧 该喝水啦</h2>  <form method="dialog"><button>好的,马上喝</button></form></dialog>
btn.addEventListener("click", () => waterDlg.showModal());

The whole popup code eliminates about thirty lines: Esc closing, focus trapping and returning, background dimming and scroll locking - all behaviors a popup should have are now handled by the browser.

And one thing the old version didn't have at all: when closing the popup, the darkening and blur animate back the way they came, not disappear instantly - that trick in old syntax requires a custom timer.

Step 4 The tooltip effect that floats attached

Another one: when the mouse hovers over a question mark icon, a small tooltip floats out to explain. The tooltip must stay attached to the question mark, not drift. Also use that new skill, open it when done.

The tooltip needs to stick to the question mark; previously you had to calculate coordinates, and track scrolling and zoom.

This time the reply had one new word: anchor positioning - the tooltip declares who it's attached to, the browser calculates its position, and it flips itself when it hits the screen edge.

image ▲ The resulting hover tooltip

Step 5 Slice open my own daily sign-in page

I have a "Lion Affairs Sign-in" folder on my D drive, a single-file sign-in page I use every day. Check how many old syntax patterns are in here. Pick the most typical one, rewrite it using the new skill, and show me the before and after side by side.

It first ran that scan command for old syntax, and it reported zero - that command only recognizes rules it's confident about, preferring to miss.

Then switching to checking against the textbook, it found a bunch. Nine popups all with hand-built tag masks; behaviors written directly on tags, fifty-plus places; innerHTML used to stuff content into the page, thirty-plus places.

The most glaring was Esc: not a single one. Popups can only be closed by clicking the small X.

I picked the sign-in success popup to slice. The old syntax looked like this:

<div class="modal-mask" id="signModal">  <div class="modal">    <button class="mx" onclick="closeModal('signModal')">✕</button>    <div class="big-ok">✓</div>  </div></div>
.modal-mask{position:fixed;inset:0;background:rgba(0,0,0,.45);  display:none;align-items:center;justify-content:center;z-index:50;}.modal-mask.show{display:flex;}

After changing per the guide:

<dialog id="signModal">  <form method="dialog">    <button class="mbtn" value="ans" autofocus>查看依据与配图</button>  </form></dialog>
dialog::backdrop{background:rgba(0,0,0,.45);}

The mask's positioning, layer, and visibility three styles are collected into one backdrop rule. Opening is just one line: dlg.showModal().

After the change I opened both versions. The popup looks the same, three things are different: there's a zoom-in and fade-in animation on open; the main button automatically gets a focus ring; Esc works.

None of these three items required a single line of code, they're built into the browser.

image

image ▲ The sign-in page before the change (top) and after (bottom)

It wasn't just one popup changed. That hand-built mask is the common base for nine popups.

Step 6 Compare side by side

Finally help me sort out these things: put the two versions of popup code side by side and compare, which one is better to maintain and why; for the tooltip effect, roughly how much more would the traditional syntax require? Keep it simple, not too long.

The popup conclusion in one sentence: the new syntax is more maintainable not because there's less code, but because it removes a bunch of things you must remember to write correctly - focus return, Esc handling, and so on. Forget them and you get invisible bugs that are hard to test. Less code is just the result.

The tooltip is a line count: calculating coordinates, tracking scroll and zoom, preventing drift, closing on outside click - adding up each item, sixty to a hundred lines; the new syntax is three lines of positioning declarations plus two tag attributes, and zero JS.

In closing

The sign-in page popup: after the change, I pressed Esc and it closed itself, and focus returned to the original button.

These things were never done in the old version. I'd used it for years and nobody noticed anything missing; hand-built syntax doesn't remind you these need doing.

After this whole experiment, this textbook actually manages one thing: it takes what the browser would do anyway out of your code.

The above is a complete field-test record, six prompts can be reused directly; distill the process: control group before install → same requirement redo after install → slice real code. Change only the path in the prompts for a different project, and you get your own front-end modernization checkup.