JavaScript Navigator connection Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Experimental

What You’ll Learn

navigator.connection returns a NetworkInformation object — hints about bandwidth and connection quality. Learn effectiveType, downlink, rtt, saveData, change events, five examples, and try-it labs.

01

Kind

Read-only property

02

Returns

NetworkInformation

03

Status

Experimental

04

Quality

effectiveType

05

Speed

downlink / rtt

06

Data saver

saveData

Introduction

Not every visitor has a fast, unlimited network. Some are on slow mobile data, some have “Data Saver” turned on, and some switch between Wi‑Fi and cellular.

The Network Information API exposes those hints through navigator.connection. You can use them to pick HD vs SD video, smaller images, or fewer background syncs — when the browser supports the API.

💡
Hints, not guarantees

Values are estimates. Always keep a solid default experience for browsers without navigator.connection (common in Safari and Firefox).

Understanding the connection Property

Think of navigator.connection as a read-only dashboard for the current network. You do not assign to it — you read properties on the object it returns.

  • effectiveType — coarse quality: slow-2g, 2g, 3g, or 4g.
  • downlink — estimated bandwidth in Mbps.
  • rtt — estimated round-trip time in milliseconds.
  • saveDatatrue when reduced data usage is requested.
  • type — connection kind (for example wifi, cellular) where supported.
  • change event — fires when connection information updates.

📝 Syntax

General form of the property:

JavaScript
navigator.connection

Value

  • A NetworkInformation object describing the system connection (or undefined if unsupported).

Common patterns

JavaScript
const conn = navigator.connection;

if (conn) {
  console.log(conn.effectiveType); // e.g. "4g"
  console.log(conn.downlink);      // Mbps estimate
  console.log(conn.rtt);           // ms estimate
  console.log(conn.saveData);      // true | false

  conn.addEventListener("change", () => {
    console.log("connection changed:", conn.effectiveType);
  });
}

⚡ Quick Reference

GoalCode
Get NetworkInformationnavigator.connection
Detect API!!navigator.connection
Quality labelconnection.effectiveType
Bandwidth estimateconnection.downlink
Latency estimateconnection.rtt
Data saver?connection.saveData
Listen for updatesconnection.addEventListener("change", fn)

🔍 At a Glance

Four facts to remember about navigator.connection.

Returns
NetworkInformation

API object

Status
experimental

Not Baseline

Key field
effectiveType

Quality hint

Best use
adaptive

Optional upgrade

📋 connection vs Online Events

navigator.connectiononline / offline
AnswersHow fast / metered?Are we online at all?
DetaileffectiveType, downlink, rttBoolean connectivity
SupportLimited / experimentalWidely available
Best forAdaptive media qualityQueue sync / retry
Use together?Yes — online status for reachability; connection for quality when present

Examples Gallery

Examples follow MDN Network Information / navigator.connection patterns. Prefer Try It Yourself to inspect your own browser. Use View Output for expected messaging.

📚 Getting Started

Detect the API and read the quality label.

Example 1 — Feature Detection

Check whether navigator.connection exists.

JavaScript
const supported = !!navigator.connection;
console.log(supported ? "connection available" : "connection missing");
Try It Yourself

How It Works

Never assume the API exists. Branch to a default “full quality” path when it is missing.

Example 2 — Read effectiveType

Print the coarse connection quality label.

JavaScript
const conn = navigator.connection;
if (!conn) {
  console.log("unsupported");
} else {
  console.log("effectiveType: " + conn.effectiveType);
}
Try It Yourself

How It Works

MDN: use this to choose high-definition vs low-definition content based on the user’s connection.

📈 Practical Patterns

Metrics, adaptive quality, and change listeners.

Example 3 — downlink, rtt, saveData

Log the common NetworkInformation metrics together.

JavaScript
const conn = navigator.connection;
if (!conn) {
  console.log("unsupported");
} else {
  const lines = [
    "effectiveType: " + conn.effectiveType,
    "downlink: " + conn.downlink + " Mbps",
    "rtt: " + conn.rtt + " ms",
    "saveData: " + conn.saveData
  ];
  console.log(lines.join("\n"));
}
Try It Yourself

How It Works

Treat numbers as approximate. Prefer saveData and effectiveType for simple product decisions.

Example 4 — Adaptive Quality Helper

Pick a media quality tier from connection hints.

JavaScript
function pickMediaQuality() {
  const conn = navigator.connection;
  if (!conn) return "high"; // safe default when unsupported
  if (conn.saveData) return "low";
  const t = conn.effectiveType;
  if (t === "slow-2g" || t === "2g") return "low";
  if (t === "3g") return "medium";
  return "high";
}

console.log("quality: " + pickMediaQuality());
Try It Yourself

How It Works

Default to high quality when the API is missing so Safari/Firefox users are not punished.

Example 5 — Listen for change

Update UI when the connection information changes.

JavaScript
const conn = navigator.connection;
const out = [];

function report(label) {
  if (!conn) {
    out.push(label + ": unsupported");
    return;
  }
  out.push(label + ": " + conn.effectiveType);
}

report("initial");
if (conn) {
  conn.addEventListener("change", function () {
    report("changed");
    console.log(out.join("\n"));
  });
}
console.log(out.join("\n"));
// Toggle network / Data Saver in DevTools to see "changed" in Try It
Try It Yourself

How It Works

In Chromium DevTools you can often simulate network conditions to trigger change.

🚀 Common Use Cases

  • Adaptive images / video — lower resolution on 2g / slow-2g.
  • Respect Data Saver — skip autoplay or prefetch when saveData is true.
  • Defer heavy work — delay analytics batches or large uploads on slow links.
  • UX messaging — gently warn before starting a large download.
  • Progressive enhancement — improve Chromium experiences without breaking Safari/Firefox.

🧠 How navigator.connection Works

1

Feature-detect

Check navigator.connection before reading fields.

Detect
2

Read NetworkInformation

Use effectiveType, downlink, rtt, saveData.

Hints
3

Adapt the experience

Choose media quality or skip expensive work.

Adapt
4

Optional: listen for change

Update quality when the connection hint changes.

📝 Notes

  • Experimental / not Baseline — support is limited (mainly Chromium).
  • Not deprecated — useful as progressive enhancement where available.
  • Values are estimates; do not treat them as precise measurements.
  • Combine with online/offline events for reachability, not only quality.
  • Related: contacts, Window, JavaScript hub.

Limited Browser Support

navigator.connection (Network Information API) is Experimental and not Baseline. Chromium-based browsers lead support; Safari and Firefox typically do not expose it. Always feature-detect and keep a default experience.

Experimental · Not Baseline

Navigator.connection

Use effectiveType / saveData as optional hints for adaptive loading — never as a hard requirement.

Limited Not Baseline
Google Chrome Network Information (effectiveType and related) supported
Supported
Microsoft Edge Chromium Edge — follows Chrome Network Information support
Supported
Opera Chromium-based — Network Information generally available
Supported
Mozilla Firefox Not available for typical web content
Unavailable
Apple Safari Not available (desktop / iOS)
Unavailable
connection Limited

Bottom line: Detect navigator.connection, adapt when present, and ship a solid default for unsupported browsers.

Conclusion

navigator.connection is the Network Information API entry point. Feature-detect it, read effectiveType / saveData as hints, adapt media when helpful, and keep a strong default for browsers without the API.

Continue with contacts, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect before reading fields
  • Default to a good experience when unsupported
  • Respect saveData when it is true
  • Use effectiveType for simple quality tiers
  • Listen for change if quality can update live

❌ Don’t

  • Require connection for core features
  • Treat downlink/rtt as exact lab measurements
  • Block Safari/Firefox users with a worse default
  • Ignore Data Saver preferences
  • Ship without a fallback path

Key Takeaways

Knowledge Unlocked

Five things to remember about connection

Network hints for adaptive loading — experimental and optional.

5
Core concepts
📶 02

Quality

effectiveType

Hint
03

Speed

downlink / rtt

Estimate
💾 04

Data saver

saveData

Respect
🔬 05

Status

Experimental

Detect

❓ Frequently Asked Questions

It is a read-only Navigator property that returns a NetworkInformation object with details about the device’s network connection — for example effectiveType, downlink, rtt, and saveData.
Yes. The Network Information API is experimental / not Baseline. Support is strongest in Chromium-based browsers; Safari and Firefox typically do not expose it. Always feature-detect.
A coarse connection quality label such as "slow-2g", "2g", "3g", or "4g". Use it as a hint for adaptive loading (for example lower image quality on slow-2g or 2g).
downlink is an estimate of bandwidth in megabits per second. rtt is an estimate of round-trip time in milliseconds. Values are approximate and can change.
A boolean that is true when the user (or browser) has requested reduced data usage. Prefer lighter assets when saveData is true.
No. The property is read-only. You read fields on the NetworkInformation object and can listen for its change event.
Did you know?

MDN’s classic use case for navigator.connection is choosing high-definition vs low-definition content from the user’s connection — still the best mental model for beginners.

Learn contacts Next

Contact Picker API for user-shared contact fields.

contacts →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful