1,007 karma · joined Mar 23, 2012 (14y ago) · 128 submissions
2.
Top 10 things AI gets wrong in web development(developer.chrome.com ↗)
5 points · by philipwalton · 1w ago · discuss
comment 2w ago · link · parent
comment 2w ago · link · parent
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.
comment 2w ago · link · parent
> 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...
comment 2w ago · link · parent
comment 2w ago · link · parent
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).
comment 2w ago · link · parent
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).
comment 2w ago · link · parent
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.
comment 2w ago · link · parent
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.
comment 2w ago · link · parent
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.
comment 7y ago · link · parent
I probably should have been clearer in the article. I was trying to strike a balance between:
- presenting what I believe to be a compelling and exciting possible future for the web (especially considering it has a viable polyfill story) - getting developers excited about this future and thinking about how it could integrate with existing tooling
and:
- Asking for feedback on the KV Storage and Import Maps APIs themselves. - Encouraging developer to experiment and/or sign up for the origin trial
It's not an easy balance to strike, and in this case I probably should have emphasized more that this is still in the experimentation phase.
I can update the article to make that more clear.
comment 8y ago · link · parent
However, scripts loaded before the `load` event do delay the load event, and analytics script are typically loaded with the lowest priority, so they're usually last and thus the ones you notice in the bottom-left corner of your window.
But the only way they'd be "blocking" anything is if the site was waiting for the load event to initialize any critical functionality (which it shouldn't be).
comment 8y ago · link · parent
The reason for its size is my site is my playground. It's where I get to experiment with all the things I want to experiment with.
I also work on quite a few open source projects, which I usually test on my site before releasing them publicly just to make sure they work in production without errors.
comment 8y ago · link · parent
And yes, clearly removing the analytics code would have also solved the problem for me, and in many cases, removing code is the best solution.
In this particular case I couldn't remove any code because I was refactoring an open source library that a lot of people use. I wanted to try to make it better for input responsiveness in general, so people who use the library (and maybe don't know much about performance) will benefit for free.
Also, I wanted to help educate people about how tasks run on the browser's main thread, and how certain coding styles can lead to higher than expected input latency.
Anyway, glad you enjoyed the post!
comment 8y ago · link · parent
Two things though:
1. I used to work on Google Analytics, and I've created a lot of open source libraries around Google Analytics, which I use on my own site because I like to test my own libraries (and feel any pain they may be causing). The way most people use Google Analytics does not block for nearly this long.
2. I've updated my Google Analytics libraries to take advantage of this strategy [1], and I'm working with some of my old teams internally to see if they can bake it in to GA's core analytics.js library, because I strongly believe that analytics code should never degrade the user experience.
comment 8y ago · link · parent
As I was doing my research for the article, I found a lot of things that really surprised me. And I feel pretty confident in saying that most web developers aren't aware of these things either.
Here are my top four:
- We shouldn't use the unload event. Ever.
- The unload event often doesn't fire when closing tabs/app on mobile
- The pagehide/pageshow events even exist (virtually no one I've talked to knows what they do; most people think they're about page visibility).
- In browsers that implement a page navigation cache, you can click a link to navigate away and then navigate back with the back button, and all your JS code is exactly as it was before you navigated.
To this last point. Try doing this in the console:
1. Write a promise that resolves in a setTimeout after 5 seconds.
2. After 1 second, click a link to navigate to a new page.
3. Stay on that page for an hour.
4. Click that back button.
5. Your promise will resolve in 4 seconds!
comment 8y ago · link · parent
Microsoft made a public statement of support for the API, and Firefox engineers were actively involved in many of the design and implementation discussions.
You can read more details in the Intent to Ship thread here: https://groups.google.com/a/chromium.org/d/msg/Blink-dev/Na7...
comment 9y ago · link · parent
[EDIT: it looks like this is already supported, here's the documentation explaining how to do it: https://webpack.js.org/configuration/configuration-types/#ex...]
Service Worker already introduced the need (or you could argue possibility) to have multiple configs since SW code has a much different transpiling baseline compared to legacy browser code. And module code just adds one more level to this.
I think webpack dev server will update if this practice becomes popular, but for the moment I think your idea of only building the es2015 build in dev mode is probably the best temporary solution (as long as you make sure to run your test suite in multiple environments and include the legacy build there).
comment 9y ago · link · parent
Every autotrack plugin that sends hits has two configuration options that enable full customization over exactly what fields get sent with each hit.
The options are `fieldsObj` and `hitFilter`: https://github.com/googleanalytics/autotrack/blob/master/doc...
comment 9y ago · link · parent
comment 9y ago · link · parent
As for a comparison of it vs. the GTM setup used by thenextweb, I briefly explain my thoughts on GTM in another comment here: https://news.ycombinator.com/item?id=13648771
comment 9y ago · link · parent
Here are a few examples off the top of my head of things you can't do with GTM today (without writing custom code):
- Tracking when (and how long) the page was in the visible vs hidden state.
- Tracking anything performance-related.
- Tracking when DOM elements are visible in the viewport (via IntersectionObserver).
- Tracking the active media query / breakpoint.
- Tracking social widget button usage.
- Tracking the use of service worker
- Tracking interactions with native web push notifications.
I think GTM is great for marketing websites, but for better understanding how someone is using a complex web app, I think it makes more sense to have that logic in the application code.