DEV Community

loading...

Discussion on: Share a quick tip you learned about web dev this year

Collapse
adirtyshame profile image
Thomas • Edited

I recently found an article describing online/offline detection. It's as easy as:
window.addEventListener('online', () => console.log('online'))
Works for 'offline' events too. You could also check for 'navigator.onLine'

Collapse
urielbitton profile image
Uriel Bitton Author

Oh nice. I believe Dev uses a version of that to disolay th3 doodle wheb youre offline ;)

Collapse
thomasbnt profile image
Thomas Bnt
Thread Thread
urielbitton profile image
Uriel Bitton Author

Nice