Install Nothing: App UIs With Native Browser APIs

Rate this content
Bookmark

You might not need as much JS as you think to accomplish common UI patterns with these new native browser APIs. Dive into new and future CSS, HTML and JS APIs that make our code leaner and faster to ship.

This talk has been presented at JSNation 2024, check out the latest edition of this JavaScript Conference.

FAQ

The Syntax Podcast is a podcast about JavaScript hosted by Scott Talinsky and Wes Boss. It airs three times a week.

The ship score indicates whether a new API should be checked out now, tried now because it’s coming soon, or can be shipped today.

The Web Animations API is a browser API that allows for animations using JavaScript. It is well supported and can be used to create animations without a CSS library.

Scott Talinsky's talk covers real demos that run on HTML, CSS, and JavaScript, focusing on new or underutilized browser APIs. He also discusses modals, alerts, dialogues, web animations API, view transitions API, and more.

Scott Talinsky is the co-host of the Syntax Podcast and an executive producer at Sentry.

Yes, the dialogue element is available in 96% of browsers and can be used today.

The View Transitions API allows for smooth transitions between different views or states in a web application. It is currently supported by 72% of browsers.

All the demos mentioned in Scott Talinsky's talk can be found on his website, tolin.ski.

The Scroll Snap API allows for creating smooth, swipeable elements without JavaScript. It is widely supported and can be used today.

The Anchor API allows elements to be anchored relative to each other. It is currently in discussion and implemented in Chrome but not yet available in all browsers.

Scott Tolinski
Scott Tolinski
31 min
13 Jun, 2024

Comments

Sign in or register to post your comment.
Video Summary and Transcription
This Talk introduces real demos using HTML, CSS, and JavaScript to showcase new or underutilized browser APIs, with ship scores provided for each API. The dialogue element allows for the creation of modals with minimal JavaScript and is supported by 96% of browsers. The web animations API is a simple and well-supported solution for creating animations, while the view transitions API offers easy animation workarounds without CSS. The scroll snap API allows for swipers without JavaScript, providing a smooth scrolling experience.

1. Introduction to Browser APIs and Demos

Short description:

Hey, how's everybody doing? I am the co-host of the Syntax Podcast. We're doing a lot over at Syntax. Today, we'll be looking at real demos using HTML, CSS, and JavaScript. These demos showcase new or underutilised browser APIs. No frameworks or build steps required. After showing each API, I'll provide a ship score. I have many demos for this talk, available on my website too.

♪♪♪ Hey, how's everybody doing? Whoo! Sick. Cool. Hey. What's up? My name is Scott Talinsky. I am the co-host of the Syntax Podcast. It's a podcast I do three times a week with Wes Boss. We talk about JavaScript. It's pretty sick. I'm also an executive producer over at Sentry where I get to work on Syntax full-time. In fact, we're doing a lot over at Syntax right now, beyond just the podcast. We have a YouTube channel and a lot going on on the website, so check it out at syntax.fm.

So, what am I going to be talking about today? Well, we're going to be taking a look at some real demos, and all of these demos run entirely on HTML, CSS, and JavaScript. There's no frameworks, nothing, no build steps. These are going to be looking at new or potentially underutilised browser APIs, some of which you've probably seen before, some of which maybe you haven't, and maybe you didn't know you were able to use them today. So, again, all of these demos, they can be loaded directly into Chrome, no build, no framework.

In addition to that, after I show you a new API, I will be giving it a ship score, and that ship score is either going to be you should check it out now, something you should be aware of, you should try it now because it is really coming down the pipe, or you can ship it. You can ship it today. I have a lot of demos, and another QR code for you. I have so many demos for this talk, I couldn't fit them all in the slides, and not only that, I didn't want to spend too much time on the code itself. So I'm going to breeze through a lot of the code, but we're going to talk a lot about the APIs themselves. I will have this available at the end of the talk too, so I'm going to tab forward. You can find it on my website, Tolin.ski as well.

2. Using the Dialogue Element for Modals

Short description:

Have you ever built UIs like modals, menus, mobile navs, drawers, or slideshows? We often reach for JavaScript frameworks to create them. But another option is to use browser APIs. Let's start with the dialogue element, which allows you to create modals with minimal JavaScript. It provides accessibility features and works with React, Vue, and other frameworks. The dialogue element is supported by 96% of browsers, making it a viable choice for shipping your project.

Have you ever built any of the following UIs? A modal, a menu, a mobile nav, a drawer, a slideshow? I would imagine so. These are the types of things that we build all the time, right? Typically, if you're building one of these things, you might reach for your JavaScript framework, right? Me personally, it's really easy to have a state variable and just toggle that state variable, throw a little animation on it, and the next thing you know, you have a modal, right?

But, you know, another thing we might do is head to npm install and bring in who knows what into our application. It could be anything. The first one I'm going to talk about is modals, alerts, and dialogues. The first demo we have here is just a basic modal. This is using the dialogue element in HTML. You can see it is still using JavaScript. In fact, most of these demos will still use JavaScript. We're just going to be using less JavaScript, and so all we're doing here really is some query selectors and calling show modal. Next thing you know, we have a modal. What's so cool about this is it applies a nert to your page so you don't have to do the overflow hidden trick to prevent scrolling. It also gives you keyboard shortcuts so you can hit escape to close it, but in addition to that, it captures your focus so you can start typing right away. All of these accessibility things that we would typically have to code ourselves. But not only that, we hardly have to write any JavaScript to get this working. You can use these techniques exactly with React, Vue, Solid, anything, you can use these techniques, right? It's not beholden to vanilla JS. The dialogue element. Could you ship the dialogue element today, and are you shipping the dialogue element today? Yes. This thing is available in 96 per cent of browsers.

I didn't tell you this, but each time we get a ship it, I'm going to have a break-dancing gif. This guy is the Olympic representative for the Netherlands in the Paris Olympics 2024. This is your Olympic representative. He's really good. All right. So you might have seen 96 per cent, thought, all right, 96 per cent, not 100, but a lot of these things are never going to get to 100, and if you see something 96, 95, anywhere in there, as long as it's supported by the big three, you can imagine that it's most likely shippable. Many of these things have polyfills if you need to support further back. I would imagine a lot of you are shipping Grid today. Grid only has 97.25 if it's unprefixed. Prefixed, even 97.7. Getting into that 97, 96 per cent range is pretty good. So if we wanted to animate this, we could bring in web animations API, or WAPI, and if we open this, you can see we get a nice little animated dialogue.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Pushing the Limits of Video Encoding in Browsers With WebCodecs
JSNation 2023JSNation 2023
25 min
Pushing the Limits of Video Encoding in Browsers With WebCodecs
Top Content
Watch video: Pushing the Limits of Video Encoding in Browsers With WebCodecs
This Talk explores the challenges and solutions in video encoding with web codecs. It discusses drawing and recording video on the web, capturing and encoding video frames, and introduces the WebCodecs API. The Talk also covers configuring the video encoder, understanding codecs and containers, and the video encoding process with muxing using ffmpeg. The speaker shares their experience in building a video editing tool on the browser and showcases Slantit, a tool for making product videos.
WebHID API: Control Everything via USB
JSNation 2022JSNation 2022
23 min
WebHID API: Control Everything via USB
Today's Talk introduces the webHID API, which allows developers to control real devices from the browser via USB. The HID interface, including keyboards, mice, and gamepads, is explored. The Talk covers device enumeration, input reports, feature reports, and output reports. The use of HID in the browser, especially in Chrome, is highlighted. Various demos showcase working with different devices, including a DualShock controller, microphone, gamepad, and Stream Deck drum pad. The Talk concludes with recommendations and resources for further exploration.
Visualising Front-End Performance Bottlenecks
React Summit 2020React Summit 2020
34 min
Visualising Front-End Performance Bottlenecks
React's web-based tools allow for independent learning. Dazzone, a sports streaming service, faces challenges with low memory and CPU targets. Measuring, analyzing, and fixing performance issues is crucial. Virtualization improves rendering efficiency and performance. The application is now much faster with significantly less jank.
Automate the Browser With Workers Browser Rendering API
JSNation 2024JSNation 2024
20 min
Automate the Browser With Workers Browser Rendering API
The Talk discusses browser automation using the Worker's Browser Rendering API, which allows tasks like navigating websites, taking screenshots, and creating PDFs. Cloudflare integrated Puppeteer with their workers to automate browser tasks, and their browser rendering API combines remote browser isolation with Puppeteer. Use cases for the API include taking screenshots, generating PDFs, automating web applications, and gathering performance metrics. The Talk also covers extending sessions and performance metrics using Durable Objects. Thank you for attending!
MIDI in the Browser... Let's Rock the Web!
JSNation 2022JSNation 2022
28 min
MIDI in the Browser... Let's Rock the Web!
MIDI is a versatile communication protocol that extends beyond music and opens up exciting possibilities. The Web MIDI API allows remote access to synths and sound modules from web browsers, enabling various projects like music education systems and web audio-based instruments. Developers can connect and use MIDI devices easily, and the Web MIDI API provides raw MIDI messages without semantics. The WebMidi.js library simplifies working with the Web MIDI API and offers a user-friendly interface for musicians and web developers. MIDI on the web has generated significant interest, with potential for commercial growth and endless possibilities for web developers.
Web Push Notifications Done Right
JSNation 2023JSNation 2023
11 min
Web Push Notifications Done Right
Let's talk about web push notifications and their benefits. Web push notifications have higher opt-in and click rates compared to traditional methods. The web push API should be used responsibly, with subscription requests initiated only after explicit user action. Improve engagement by using emojis in notifications. Connect with the speaker on LinkedIn for more information about the web push API.

Workshops on related topic

Writing Universal Modules for Deno, Node and the Browser
Node Congress 2022Node Congress 2022
57 min
Writing Universal Modules for Deno, Node and the Browser
Workshop
Luca Casonato
Luca Casonato
This workshop will walk you through writing a module in TypeScript that can be consumed users of Deno, Node and the browsers. I will explain how to set up formatting, linting and testing in Deno, and then how to publish your module to deno.land/x and npm. We’ll start out with a quick introduction to what Deno is.