DEV Community

0 seconds of 5 minutes, 57 secondsVolume 90%
Press shift question mark to access a list of keyboard shortcuts
00:00
00:00
05:57
 
James Bubb
James Bubb

Posted on

6 3

Using JavaScript Online / Offline Events

Originally published here on YouTube.
(Please give me a thumbs up and subscribe if you found this useful or follow me on Twitter: https://www.twitter.com/codebubb 🙏).

00:00 Introduction
00:34 The navigator object
01:28 Setting up events
02:39 Updating a UI
05:00 Connection speed

So we'll start off our JavaScript tutorial by looking at the Navigator object and see how you can use the onLine property to determine the user's current network status.

Then we'll move on to looking at the JavaScript Online Offline events and see how you can set up a couple of simple event listeners to detect when the user's network connection changes.

Once you understand how the two JavaScript Online Offline events work, we'll create a simple example that demonstrates how to update a bit of UI to display to the user the status of the current network connection.

Finally, we'll take a look at the connection property that's also available on the Navigator object and see how you can use this to gain further information about a user's network connection.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (2)

Collapse
 
zippytyro profile image
Shashwat Verma

that was really helpful.

Collapse
 
codebubb profile image
James Bubb

Cheers! Glad you found it useful.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs