DEV Community

Play Button Pause Button
James Bubb
James Bubb

Posted on

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.

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.