{"id":4302,"date":"2024-11-15T13:59:55","date_gmt":"2024-11-15T18:59:55","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=4302"},"modified":"2024-11-19T11:51:58","modified_gmt":"2024-11-19T16:51:58","slug":"showing-browser-support-for-web-platform-features-on-your-own-blog","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/showing-browser-support-for-web-platform-features-on-your-own-blog\/","title":{"rendered":"Showing Browser Support for Web Platform Features on Your Own Blog"},"content":{"rendered":"\n<p>It&#8217;s a responsible thing to do to mention the browser support of web platform features when you write about them. I could probably do better than I do. <\/p>\n\n\n\n<p>What I tend to do is go for what I feel like the biggest highlights, as well as stick to the Big Three: Chrome, Firefox, and Safari. Saying &#8220;this only works in Safari right now&#8221; is pretty important information to know, or, &#8220;this works in Chrome and Firefox and we&#8217;re waiting for Safari support.&#8221;<\/p>\n\n\n\n<p>That may be a bit simplistic. I&#8217;m aware Edge exists, for the record, it just uses Chromium so it doesn&#8217;t feel particularly notable to call that out. Same story with browsers like Opera, Samsung Internet, and Arc: it&#8217;s just Chrome. If there really was a big important difference between Regular Chrome and Samsung Internet or whatever, I&#8217;d call it out, it just seems awfully rare. I typically just say &#8220;Chrome &#8216;n&#8217; Friends&#8221;. <\/p>\n\n\n\n<p>I mostly find Safari and Safari iOS not terribly different either, but if there was a serious difference it would definitely be worth calling out.<\/p>\n\n\n\n<p>I also like to link to a source that is known to update. That typically means whatever the relevant MDN page is or caniuse, which is more and more MDN powered anyway.<\/p>\n\n\n\n<p>I&#8217;ve been talking about scroll-driven animations a bunch, so linking to a highly relevant property like <a href=\"https:\/\/caniuse.com\/mdn-css_properties_animation-timeline\"><code>animation-timeline<\/code> on caniuse<\/a> I feel like is a pertinent thing to do, while also saying something like:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>At the time of this writing, scroll-driven animations are only a Chrome &#8216;n&#8217; Friends feature, but I see feature flags in both Safari and Firefox so it&#8217;s coming!<\/p>\n<\/blockquote>\n\n\n\n<p>That caniuse page pulls data directly from MDN anyway, so a link <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/animation-timeline#browser_compatibility\">directly to the browser support for that property<\/a> is probably even better. That&#8217;s what hash links are for I suppose.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What to Avoid<\/h2>\n\n\n\n<p>Screenshots of browser support tables. It&#8217;s just going to go out of date, probably faster than you think. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Live Updating Embeds<\/h2>\n\n\n\n<p>Ire Aderinokun&#8217;s <a href=\"https:\/\/caniuse.bitsofco.de\/\">CanIUse Embed<\/a> takes this job on. It sucks the data in from caniuse (or MDN) then produces an iframe of that feature. Here&#8217;s what it produces for the <code>text-decoration-skip-ink<\/code> feature:<\/p>\n\n\n\n<script src=\"https:\/\/cdn.jsdelivr.net\/gh\/ireade\/caniuse-embed\/public\/caniuse-embed.min.js\"><\/script>\n\n<p class=\"ciu_embed\" data-feature=\"mdn-css__properties__text-decoration-skip-ink\" data-periods=\"future_1,current,past_1,past_1\">\nData on support for the animation timeline feature across the major browsers\n<\/p>\n\n\n\n<p>That&#8217;s pretty neat, but&#8230;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The CanIUse Embed is probably worth avoiding for now<\/h3>\n\n\n\n<p>While it&#8217;s still mostly functional, I think <a href=\"https:\/\/caniuse.bitsofco.de\">the page<\/a> has fallen just enough out of date that it&#8217;s best to avoid using.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The &#8220;Select Feature&#8221; dropdown doesn&#8217;t have much by way of new features. Nothing I was trying to use it for was there: scroll-driven animations, anchor positioning, etc.<\/li>\n\n\n\n<li>The data seems weirdly wrong. Try the CSS selector <code>:has()<\/code> \u2014 it lists no support in any browser. That <code>text-decoration-skip-ink<\/code> chart above? That&#8217;s also kinda wrong. <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/text-decoration-skip-ink#browser_compatibility\">The MDN chart<\/a> is much more nuanced, listing support by sub-feature, and accurate. <\/li>\n\n\n\n<li>It gives you invalid HTML, with nested <code>&lt;p&gt;<\/code> tags. <\/li>\n\n\n\n<li>It doesn&#8217;t link out to a useful canonical source for the specific data.<\/li>\n<\/ul>\n\n\n\n<p>It&#8217;s a cool idea and it could be fixed up, but it&#8217;s pretty busted for right now.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using Baseline<\/h2>\n\n\n\n<p>Google has been working on <a href=\"https:\/\/web.dev\/baseline\">Baseline<\/a> for years now. It&#8217;s a bit of a simplified version of understanding browser support. They&#8217;ve just recently <a href=\"https:\/\/github.com\/web-platform-dx\/baseline-status?tab=readme-ov-file\">released a web component<\/a> for displaying the Baseline widget wherever. <\/p>\n\n\n\n<p>Here is their example usage:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/cdn.jsdelivr.net\/npm\/baseline-status@1.0.4\/baseline-status.min.js\"<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"module\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">baseline-status<\/span> <span class=\"hljs-attr\">featureId<\/span>=<span class=\"hljs-string\">\"anchor-positioning\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">baseline-status<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/baseline-status@1.0.4\/baseline-status.min.js\" type=\"module\"><\/script>\n\n<baseline-status featureId=\"anchor-positioning\"><\/baseline-status>\n\n\n\n<p>It requires you know what the <code>featureId<\/code> is for whatever you want to embed, and it looks like the place to find that information is <a href=\"https:\/\/github.com\/web-platform-dx\/web-features\/tree\/main\/features\">this folder on GitHub<\/a>. <\/p>\n\n\n\n<p>So it&#8217;s useful, compact, and up-to-date, it&#8217;s also limited to what they&#8217;ve got data on at the moment, which ain&#8217;t everything. I couldn&#8217;t find the <code>animation-timeline<\/code> I&#8217;ve been using as an example, for instance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What I&#8217;d Like to See<\/h2>\n\n\n\n<p>Browser support is nuanced, but <em>just a little<\/em>. If you see a big \u274c next to a scroll-driven animations or view transitions feature, you could be put off it and become sour to the idea of learning about new features too soon. But those features are <em>easily<\/em> progressive enhancement territory. It doesn&#8217;t mean don&#8217;t use it in the same way, say, something like file browser APIs, which directly affect certain apps core experience.<\/p>\n\n\n\n<p>When a feature isn&#8217;t supported in a browser, I feel it&#8217;s very pertinent information to say: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Not supported, but it&#8217;s polyfillable!<\/li>\n\n\n\n<li>Not supported, but it&#8217;s basic progressive enhancement territory!<\/li>\n<\/ul>\n\n\n\n<p>I&#8217;d love it if these browser support charts\/widgets could be more clear about that.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The &#8220;When&#8221;<\/h2>\n\n\n\n<p><a href=\"https:\/\/rachelandrew.co.uk\/archives\/2024\/11\/15\/when-is-the-right-time-to-share-our-excitement-about-new-web-features\/\">Rachel Andrew<\/a>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>There\u2019s a good number of developers who love to hear about new things landing on the platform. However there\u2019s a much larger group of people who really just want to do their jobs, and who can\u2019t invest time learning new things until they can use the new things. If we publish all of our material when things are experimental or only available in a single browser, all the noise happens at the wrong time. This leads to people missing the fact that things have become available everywhere. So, don\u2019t forget to write about the Newly and Widely available things, you\u2019ll be speaking to a much bigger audience, and providing people with something they can use in their production sites right away.<\/p>\n<\/blockquote>\n\n\n\n<p>I feel like that&#8217;s good advice for this very website. There is plenty to talk about on the web without <em>so much<\/em> focus on the very newest and most experimental.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Baseline now has a baseline-status web component widget that can be used anywhere to show of general browser support. This post gets into what else there is to think about there.<\/p>\n","protected":false},"author":1,"featured_media":4452,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[73,72],"class_list":["post-4302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-post","tag-baseline","tag-browser-support"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/11\/baseline.png?fit=1408%2C682&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/4302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=4302"}],"version-history":[{"count":25,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/4302\/revisions"}],"predecessor-version":[{"id":4527,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/4302\/revisions\/4527"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/4452"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=4302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=4302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=4302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}