Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap
In this video we'll discuss JavaScript Offline / Online / Internet Connection Detection methods and I'll provide a modern JS solution with Async / Await. All in less than 6 minutes!
My article in #freeCodeCamp news: (includes async load event I forgot to put in video!)
https://www.freecodecamp.org/news/how-to-check-internet-connection-status-with-javascript/
Quick Concepts outline:
• navigator.onLine
• online and offline events
• Seems good, but there is a problem
• CanIUse.com navigator.onLine notes
• MDN web docs on navigator.onLine
• A Better Modern JS Solution
GitHub Gist for the code: https://gist.github.com/gitdagray/f310be81be217750fc9d2b233e2ae70c
Further Reading:
MDN Web Docs - navigator.onLine: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine
MDN Web Docs - setInterval: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval
MDN Web Docs - Async & Await: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await
Follow Me:
Twitter: https://twitter.com/yesdavidgray
Medium: https://medium.com/@davegray_86804
#Javascript #Internet #Connection