Tiny Frontend Logo
Posts 0125

On This Page

Data Transfer with WebSocket

You're probably already familiar with using the HTTP protocol to retrieve data from servers. However, in addition to HTTP, browsers also provide another networking protocol to meet more advanced communication needs: WebSocket.

If you've never used WebSocket in your projects before, keep reading as we explore the world of WebSocket.

What is WebSocket?

WebScocket is a real-time web technology that facilitates bidirectional, full-duplex communication between clients and servers over a persistent connection.

It's built on top of the existing TCP protocol and can send text or binary data. Additionally, it is not restricted by the same-origin security policy, allowing communication with any server.

Its protocol identifier is ws, if encrypted, it becomes wss. The complete URL format is as follows:

ws://socket-server.com/path

Why WebScocket?

Compared to the HTTP protocol, it has the following advantages:

Low Latency

Unlike traditional HTTP requests, which involve multiple round trips between the client and server, WebSockets maintain a persistent connection.

This minimizes latency, making them ideal for real-time scenarios like chat applications, live notifications, and online gaming.

Efficient Data Transfer

WebSockets allow bidirectional communication, enabling both clients and servers to send messages without the overhead of establishing new connections for each request.

This efficiency is especially valuable when transmitting frequent updates or large datasets.

Push Notifications

WebSockets enable servers to push data to clients instantly.

For example, in a chat app, messages can be delivered immediately to all connected users without polling the server repeatedly.

Reduced Server Load

With WebSockets, servers handle fewer connection setups and teardowns, reducing resource consumption compared to long-polling or frequent AJAX requests.

Subscribe to read the full content

* Free subscribe to enjoy full content access.
* You can cancel anytime with 1-click.

Read Next

0124

Permissions on a Webpage

Your website cannot readily use some services like camera, microphone, location, etc. on the user device. For security reasons, the websites need to specifically request for permissions from the user to use these services. In this post, let's learn how to handle these permissions on a webpage.

Permissions on a Webpage
0123

Network Requests in JavaScript

One of the crucial and fundamental component of a website is to make Network Requests to fetch some data. There are a lot of libraries available now, like axios, that make this task very easy to implement for the developers. But, if you've ever wondered what goes on underneath those libraries or if you want to achieve this using pure JavaScript, keep reading.

Network Requests in JavaScript
0122

Iterators and Generators in JavaScript

Let's discover some hidden gems and not so commonly used concepts in JavaScript. Iterators and Generators bring the concept of iteration directly into the core language and provide a mechanism for customizing the behavior of for...of loops.

0121

Lazy Load Offscreen Iframes

As more websites embed YouTube videos into their pages to provide richer content, and it indeed helps users access information more effectively.

Lazy Load Offscreen Iframes
0120

Resumable File Upload

The cloud storage has become an indispensable file backup and sharing solution in our daily work. But have you ever considered:

Resumable File Upload
0119

Sending Notifications

The Notification API allows web developers to create and display desktop notifications to users.

Sending Notifications