Home
/
Network
/
Online Status
Your Current Online Status
Loading...
Copy
Technical Classification
Type: JavaScript Property (navigator.onLine)
Data Source: Browser Network Stack / Operating System
When Available: Always accessible via JavaScript
Return Type: Boolean (true or false)
Background & Purpose
The navigator.onLine property returns a boolean value indicating whether the browser is currently connected to a network. It's part of the HTML5 specification and provides a simple way to detect network connectivity status.
Historical Context:
Introduced in HTML5 to support offline web applications
Enables Progressive Web Apps (PWAs) to function without network connectivity
Works in conjunction with Service Workers for offline caching
Part of the broader effort to make web apps more resilient
Supported in all modern browsers since the early 2010s
Important Limitations:
true only means "potentially connected" - not guaranteed internet access
Can be true even if connected to a network without internet
Does not indicate connection quality or speed
May not immediately reflect network state changes
Return Values & Meanings
Possible Values:
Value
Meaning
Scenarios
true
Browser is connected to a network
• Connected to Wi-Fi
• Connected via Ethernet
• Mobile data connection active
• Local network (may not have internet)
false
Browser is not connected to any network
• Airplane mode enabled
• Wi-Fi/Ethernet disconnected
• Network adapter disabled
• "Work Offline" mode in browser
Edge Cases:
Captive Portals: May show true but require login for internet access
VPN Connecting: May temporarily show false during VPN connection
Local Network: Returns true even without internet gateway
Slow Connection: Returns true regardless of connection quality
Common Uses
Legitimate Uses:
Offline Detection: Show "You're offline" message when network disconnects
Progressive Web Apps: Switch between online and cached content
Save User Data: Prevent data loss by warning before network operations
Queue Operations: Queue sync operations until connection restored
UI Adaptation: Disable features that require network connectivity
Bandwidth Conservation: Avoid downloading large assets when offline
Error Prevention: Prevent API calls that will fail without connectivity
User Experience: Provide appropriate messaging based on connectivity state
Event Listeners:
Applications can listen for connectivity changes using events:
window.addEventListener('online', callback) - Fires when going online
window.addEventListener('offline', callback) - Fires when going offline
Example Use Case:
A note-taking app checks navigator.onLine before syncing. If offline, notes are saved locally and synced automatically when connection is restored.
Platform Differences
How Online Status is Determined:
Platform/Browser
Detection Method
Accuracy Notes
Chrome (Desktop)
OS network stack
Reliable, updates quickly
Firefox (Desktop)
OS network stack
Reliable, consistent behavior
Safari (macOS)
System network status
Very accurate with macOS integration
Edge
Windows network stack
Reliable on Windows
Mobile Browsers
Mobile OS network APIs
May have slight delays detecting changes
Older Browsers
Basic network checks
Less reliable, slower updates
Platform-Specific Behaviors:
Windows: Checks network adapter status and default gateway
macOS/iOS: Integrated with system network reachability
Linux: Varies by distribution, generally checks NetworkManager
Android: Uses ConnectivityManager APIs
Privacy Implications
Tracking Risk: LOW
Privacy Concerns:
Connection Pattern Tracking: Websites can log when you go online/offline
Activity Timing: Reveals when you're using your device
Network Instability: Frequent changes may indicate mobile user or poor connectivity
Browser Fingerprinting Component: State transitions can be logged over time
Why Low Risk:
Binary value (only two possible states) provides minimal uniqueness
Most users are "online" most of the time (very common state)
Does not reveal location, hardware, or identifying information
Necessary for basic web application functionality
Cannot be used alone for cross-site tracking
No persistent identifier associated with this value
Limited Tracking Value:
Essentially useless for fingerprinting in isolation
Only marginally useful when combined with other timing data
Cannot distinguish between different users
User Control & Protection
How to Control Online Status:
Manual Offline Mode:
Firefox: File > Work Offline (toggles offline mode)
Chrome: DevTools > Network tab > Throttling > Offline
Edge: DevTools > Network > Network throttling > Offline
System-Level Controls:
Airplane Mode: Disables all network connectivity
Disable Adapters: Turn off Wi-Fi or Ethernet in system settings
Disconnect Network: Physically disconnect Ethernet or turn off router
Developer Tools:
Browser DevTools allow simulating offline state for testing
Does not affect actual network connectivity, only browser's perception
Useful for testing offline-first web applications
Privacy Implications of Control:
Little privacy benefit to spoofing or hiding this value
Websites need accurate connectivity info for proper functionality
Blocking this API breaks many modern web features
Not targeted by privacy-focused browsers or extensions
Best Practices for Developers:
Use as a hint, not absolute truth
Always implement proper error handling for network requests
Don't rely solely on this for determining internet access
Test network requests even when onLine is true