5 really cool web technologies to know! 🤩
Tags: webdev, html, javascript, css
Published: 2021-01-09 17:56:39

Welcome to my first article in 2021! This time I'm not focusing much on [writing articles every week](https://dev.to/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2) but of course, I will continue to write useful content whenever I feel the need.

Okay okay, back to the grind...

There are some web technologies which you already know and must’ve mastered. Need examples? How about JavaScript libraries, PWAs, or even CSS Subgrids?

There are all quite common and used in most of the projects (well, I don't know about Subgrids though). But there are some more really cool ones out there about which you might or mightn’t have heard about.

Here are 5 of those about which I recently got to know about and they can be the future, who knows!

---

# 1. [Web Animation API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API) ✨

### ➡️ What is it?

> The Web Animations API **allows developers to describe animations to DOM elements by syncing animation with the help of the Timing and Animation model.**. 

### ➡️ Why use it?

It combines the best of <mark>CSS animation and transition</mark> to give you the best performance without using any external optimizations.

You can:

- Use both CSS or JavaScript. 
- Move animations from stylesheets to JavaScript easily.
- You no longer rely on writing CSS properties and scoping classes onto elements to control the playback of animations.
- You can now dynamically set values from properties to durations.

### ➡️ What about the browser support?

Here's what [caniuse.com](https://caniuse.com/web-animation) says. The red blocks mean it's not supported and the green ones symbolize it is supported. Everything in between the two colors means partial support:

![Web Animations API support](https://dev-to-uploads.s3.amazonaws.com/i/ungo5vy8b6jrm1s7hw4x.png)
<figcaption>92.67% usage</figcaption>

### ➡️ How to write the code?

Usually, if I say you to write an animation code for an HTML element, you would do something like this:

```css
#element {
  animation: animationName infinite 1s linear;
}

@keyframes animationName {
  0% {
    transform: rotate(0) translate3D(-50%, -50%, 0);
  }
  50% {
    transform: rotate(0) translate3D(-50%, 50%, 0);
  }
  100% {
    transform: rotate(360deg) translate3D(-50%, -50%, 0);
  }
}
```

For the Web Animation API you would do something like this:

```js
// 1. Representing the keyframes
var animationName = [
  { transform: 'rotate(0) translate3D(-50%, -50%, 0)' },
  { transform: 'rotate(360deg) translate3D(-50%, -50%, 0)' }
];

// 2. Representing timing properties
var animTiming = {
  duration: 1000,
  iterations: Infinity
}

//3. Applying the animation
document.getElementById("element").animate(
  animationName,
  animTiming
}
```

### ➡️ Where can I get more resources?

Apart from the documentation linked above:

- [Let’s talk about the Web Animations API](http://danielcwilson.com/blog/2015/07/animations-intro/) by Daniel C. Wilson.

- [Web Animations API improvements in Chromium 84](https://web.dev/web-animations/) by Una Kravets and Kevin Ellis.

- [web-animations-js](https://github.com/web-animations/web-animations-js) by Web Animations.


# 2. [WebRTC](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) 🔌

### ➡️ What is it?

> WebRTC or Web Real-Time Communication is a technology that **enables web apps and websites to store and stream audio/video media**, as well as to exchange data between browsers without the need of any plugin or a third-party software/tool.

### ➡️ Why use it?

Because it supports:

- Media capture.
- Media streaming.
- Video and audio conferencing.
- File transfer.
- Screen share.
- Interfacing with legacy devices.

### ➡️ What about the browser support?

Here's what [caniuse.com](https://caniuse.com/rtcpeerconnection) says:

![WebRTC Support](https://dev-to-uploads.s3.amazonaws.com/i/ggruchqnzbs4zi9laxk5.png)
<figcaption>93.91% usage</figcaption>

### ➡️ How to write the code?

Here's a quick example of sending a text message:

```js
// Signalling the server and greeting a user with a text message

//1. Get the WebSocket library 
var WebSocketServer = require('ws').Server; 

//2. Create a server at port 8080
var wss = new WebSocketServer({port: 8080});
  
//3. User connects to the sever 
wss.on('connection', function(connection) { 
   console.log("user connected"); 
	
   //4. Server gets a message from a connected user 
   connection.on('message', function(message) { 
      console.log("Got message from a user:", message); 
   }); 
	
   connection.send("Hello from server"); 
});
```

### ➡️ Where can I get more resources?

Apart from the documentation linked above:

- [samples repo](https://github.com/webrtc/samples) by webrtc.
- [WebRTC website](https://webrtc.org/).
-[Real time communication with WebRTC](https://codelabs.developers.google.com/codelabs/webrtc-web#0) by Google Codelabs.

# 3. [Web Speech API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API) 🗣

### ➡️ What is it?

> The Web Speech API enables you to **incorporate voice data** into your web apps. It has two parts: SpeechSynthesis (Text-to-Speech), and SpeechRecognition (Asynchronous Speech Recognition).

### ➡️ Why use it?

In the year 2018, [Google reported](https://www.thinkwithgoogle.com/data/voice-search-mobile-use-statistics/) that <mark>27% of the global online population</mark> is using voice search on mobile.

With speech-enabled, users can speak across the website to access the data they need.

### ➡️ What about the browser support?

Here's what [caniuse.com](https://caniuse.com/speech-synthesis) says:

![Web Speech API Support](https://dev-to-uploads.s3.amazonaws.com/i/3smsrfusifdmi97dy704.png)
<figcaption>93.85% usage.</figcaption>

### ➡️ How to write the code?

I really liked the following example to showcase the speech API by Lindsay Greene, check out the article:

{% medium https://medium.com/voice-tech-podcast/talk-to-me-beginners-tutorial-using-the-web-speech-api-8683cf736395 %}

### ➡️ Where can I get more resources?

Apart from the documentation linked above:

- [Speech to text in the browser with the Web Speech API](https://www.twilio.com/blog/speech-recognition-browser-web-speech-api) by Phil Nash.

- [web-speech-api repo](https://github.com/mdn/web-speech-api) by mdn.

- [Voice to Text with Chrome Web Speech API](https://towardsdatascience.com/voice-to-text-with-chrome-web-speech-api-d98462cb0849) by Benson Ruan.

# 4. [WebXR Device API (formerly WebVR)](https://www.w3.org/TR/webxr/) 🎮

### ➡️ What is it?

> The WebXR Device API **implements the core of the WebXR feature set**, from the selection of output devices, rendering of the 3D scenes to the chosen device, and managing motion vectors created using input controllers.

But what is this WebXR?

Just like VR is Virtual Reality, AR is Augmented Reality and MR is Mixed Reality, in a similar fashion <mark>WebXR combines a group of standards that are used together to support rendering 3D scenes for VR, or for adding graphical imagery to AR</mark>.

### ➡️ Why use it?

Although all these 'reality' based technologies are starting to boom, and you need a setup like below (which isn't much popular yet):

![WebXR Setup](https://mdn.mozillademos.org/files/11035/hw-setup.png)

Still, with this enabled you can:

- Render a 3D scene at an appropriate frame rate.
- Mirror the output to a 2D display.
- Create vectors representing the movements of input controls.
- Use the full potential of technologies like [ARCore](https://developers.google.com/ar) or use hardware like [Oculus Rift](https://www.oculus.com/rift/).
- Gain the benefit of [WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API)'s rich development tool ecosystem and a large

### ➡️ What about the browser support?

Here's what [caniuse.com](https://caniuse.com/webvr) says:

![WebXR Support](https://dev-to-uploads.s3.amazonaws.com/i/hjh0axxjvgg31204mzxa.png)
<figcaption>7.09% usage.</figcaption>

### ➡️ How to write the code?

To access the WebXR API, we use [`navigator.xr`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/xr) property of the current window which returns the [`XRSystem`](https://developer.mozilla.org/en-US/docs/Web/API/XRSystem) object.

```js
// Initiating the XR interface to use
class App {
  ...
  async init() {
    if (navigator.xr && XRSession.prototype.requestHitTest) {
      try {
        this.device = await navigator.xr.requestDevice();
      } catch (e) {
        this.onNoXRDevice();
        return;
      }
    } else {
      this.onNoXRDevice();
      return;
    }

    document.querySelector('#enter-ar').addEventListener('click', this.onEnterAR);
  }
}
```

### ➡️ Where can I get more resources?

Apart from the documentation linked above:

- [WebXR website](https://immersiveweb.dev/).
- [Building an augmented reality (AR) application using the WebXR Device API](https://codelabs.developers.google.com/codelabs/ar-with-webxr#0) by Google Codelabs.
- [Using WebXR With Babylon.js](https://www.smashingmagazine.com/2020/10/using-webxr-with-babylonjs/) by Preston So.

# 5. [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) 🎛

### ➡️ What is it?

> The WebSocket API makes it possible to **open a two-way interactive communication session between the client and a server**.

### ➡️ Why use it?

You can send messages to a server and receive event-driven responses without having to poll the server for a reply. So you can use it on social feeds, multiplayer games, collaborative environment, etc.

### ➡️ What about the browser support?

Here's what [caniuse.com](https://caniuse.com/mdn-api_websocket) says:

![Websocket Support](https://dev-to-uploads.s3.amazonaws.com/i/as9vm9n89m0v251d59gk.png)
<figcaption>95.85% usage.</figcaption>

### ➡️ How to write the code?

```js
// 1. Create a new WebSocket
var exampleSocket = new WebSocket("wss://www.example.com/socketserver", "protocolOne");

//2. Send data to the server
exampleSocket.send("Text to server");

//3. Closing the connection
exampleSocket.close();
```

### ➡️ Where can I get more resources?

- [Using WebSocket to build an interactive web application](https://spring.io/guides/gs/messaging-stomp-websocket/) by Spring.io.

- [WebSockets tutorial: How to go real-time with Node and React](https://blog.logrocket.com/websockets-tutorial-how-to-go-real-time-with-node-and-react-8e4693fbf843/) by LogRocket.

- [WebSocket](https://javascript.info/websocket) by The Modern JavaScript Tutorial.

---

Hope you liked the information. You can comment below with your thoughts about it.

And now...as always, enjoy a meme! 😆

---

# The [#DevHumour](https://twitter.com/search?q=%23devhumour&src=typed_query) Corner 😂

![Dev Humour Image](https://dev-to-uploads.s3.amazonaws.com/i/ble8edl78i03op57qru2.jpeg)

---

# Some of my previous articles

- [The importance of writing a technical article consistently. ✍️](https://dev.to/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2)
- [Bring the power of semantic HTML to make a hero section with MVP.css. 🕴](https://dev.to/vaibhavkhulbe/bring-the-power-of-semantic-html-to-make-a-hero-section-with-mvp-css-1dho)
- [Create a crazy input interaction with lax.js. 🤪](https://dev.to/dailydotdev/create-a-crazy-input-interaction-with-lax-js-51fj)

---

# Find me on

| [Twitter](https://twitter.com/vaibhav_khulbe)  | [Instagram](https://instagram.com/vaibhavkhulbe143/)   | [LinkedIn](https://www.linkedin.com/in/vaibhav-khulbe/)  | [Everywhere else](https://about.me/vaibhav_khulbe)
|---|---|---|---

---

#### [📫 Subscribe to my weekly developer newsletter 📫](https://mailchi.mp/f59beeac6b9b/devupdates)