
HTTPS, SecureContext, and Mixed Content: The Compatibility Layer Below the Platform
HTTPS is no longer just privacy — it is a feature gate. SecureContext locks Service Workers, Push, Clipboard, WebAuthn, and dozens more APIs to https://.
TL;DR: HTTPS is no longer just a privacy feature — it is a compatibility gate. The SecureContext requirement locks Service Workers, Push, Notifications, Clipboard, Geolocation, getUserMedia, Web Crypto, WebAuthn, Payment Request, Web Bluetooth / USB / Serial / HID, and dozens of other APIs to https:// (or localhost). Mixed Content rules block subresources from loading over plain HTTP. This guide covers the SecureContext API list, how mixed content rules behave in 2026, Subresource Integrity for third-party scripts, modern HTTPS configuration (HSTS, HTTP/3, ACME automation), and the audit findings that commonly surface accumulated configuration drift.
Why HTTPS became a compatibility gate
Around 2015 the web platform began conditioning powerful APIs on a SecureContext — meaning the document and all its ancestors are loaded over https:// (or localhost / file:// in development). The motivation was not just confidentiality but integrity: a feature like Service Worker, which intercepts every network request the page makes, cannot safely run over a connection an attacker can rewrite. If an attacker on the network path can modify the response that registers the Service Worker, they can install code that runs on every subsequent page load.
By 2026 the SecureContext requirement covers many of the powerful APIs developers adopt. Service Workers, Push, Notifications, Clipboard, Geolocation, getUserMedia, Web Crypto's SubtleCrypto, Payment Request, Web Bluetooth / USB / Serial / HID, WebAuthn (Passkeys), Storage Access, Web Share, and many more all gate on SecureContext. The list keeps growing: the Secure Contexts specification asks authors of sensitive new APIs to restrict them to secure contexts.
The compatibility implication is operational. A feature that works on https://example.com may not work on http://staging.example.com, and the failure may be silent — navigator.clipboard and navigator.serviceWorker are simply undefined in a non-secure context, so code that calls them throws a TypeError, and Geolocation calls the error callback with PERMISSION_DENIED, which looks like a user refusal. None of these throw user-visible errors by default; the bug appears in the console and in error-monitoring tools, not in the user interface.
Treating HTTPS as a compatibility layer rather than just a security checkbox reframes the audit. The question is not "are we encrypted" but "are all environments configured so that the platform features the application relies on actually function."
What "SecureContext" actually means
A document is a Secure Context if it was loaded over a secure transport (HTTPS) and all of its ancestors are also Secure Contexts. The "and all of its ancestors" clause is the tricky part — an iframe at https://x.com inside a parent at http://y.com is not a Secure Context, even though the iframe itself was loaded over HTTPS, and cannot use SecureContext APIs.
localhost and 127.0.0.1 are exempted as Secure Contexts for development convenience. Any port, any scheme — http://localhost:3000 is a Secure Context for the engine's purposes, which lets you develop Service Workers and Web Crypto code without configuring a local TLS certificate.
The specification says browsers should treat file:// URLs as secure but allows them to opt out, so behavior can differ between browsers. For consistent local-file testing, prefer localhost over opening HTML files directly.
Detection in JavaScript is direct:
if (window.isSecureContext) {
// SecureContext APIs are available
}window.isSecureContext returns true or false per document. The check is the right gate for code that uses SecureContext APIs; failing fast on staging configurations that lost HTTPS catches drift before it reaches production.
CSS does not have a direct SecureContext detection mechanism. Gate features that depend on SecureContext APIs in JavaScript and use @supports for the CSS-side feature checks separately.
The SecureContext API list — what fails on http://
The list grows over time. The categories below cover the APIs most teams actually use.
| Category | APIs gated on SecureContext |
|---|---|
| Storage / persistence | Service Worker registration, Cache API, `navigator.storage.persist()` |
| Sensors / capture | Geolocation, getUserMedia (camera / microphone), DeviceMotionEvent, DeviceOrientationEvent |
| Identity / payment | WebAuthn (Passkeys), Payment Request API, Credential Management |
| Hardware | Web Bluetooth, Web USB, Web Serial, Web HID, Web NFC |
| Crypto | `crypto.subtle` (WebCrypto) key operations |
| Communication | Push API, Notification constructor, Clipboard API (readText / writeText) |
| UI / platform | Web Share, getInstalledRelatedApps, Web App Manifest installability |
A handful of APIs are not gated: the View Transitions API (same-document and cross-document) and Trusted Types work on plain http:// as of October 2026, per their MDN reference pages, although both are normally deployed on HTTPS sites anyway; crypto.getRandomValues() works without SecureContext (random number generation is safe over HTTP).
The failure mode for SecureContext APIs is not consistent: APIs marked [SecureContext] in their specification, such as navigator.serviceWorker and navigator.clipboard, are simply absent, while others, such as Geolocation, stay present and fail at call time with a permission error. The right pattern is to gate the entire feature path on window.isSecureContext, not just to feature-detect the API surface.
Mixed content rules
Mixed content is the policy for what happens when an HTTPS page loads subresources over HTTP.
Active mixed content — scripts, stylesheets, iframes, XHR, fetch, WebSocket — has been blocked outright by all major engines for years (Firefox, for example, since Firefox 23 in 2013). An <script src="http://..."> inside an HTTPS page never loads. The console reports the block; the page renders as if the script never existed.
Passive mixed content — images, audio, and video — was historically allowed with a warning and has since moved to auto-upgrade in Chromium and Firefox. As of October 2026, auto-upgrade is the default in both: Chromium rolled it out in stages during 2020 (audio and video from Chrome 80, images fully from Chrome 86), and Firefox 127 followed in June 2024. For Safari the sources disagree: WebKit's Safari 18.0 release notes (September 2024) say Safari 18.0 auto-upgrades images, video, and audio in mixed-content settings, while MDN's browser compatibility data, as of October 2026, still list Safari as not supporting these upgrades, so check current Safari behavior rather than assuming either. Where auto-upgrade applies, an http:// image URL in an <img src> or a CSS background image on an HTTPS page is silently rewritten to https://, the request goes out over HTTPS, and if the upgrade succeeds the resource loads. If the upgrade fails (the upstream does not serve HTTPS), the request fails and the resource is blocked. Not every image qualifies: images set through srcset or <picture>, CORS-mode images (<img crossorigin>) and URLs whose host is an IP address are blocked rather than upgraded.
The auto-upgrade behavior hides mixed content for as long as the upstream supports HTTPS. The hidden risk is that upstreams sometimes retire HTTP-to-HTTPS redirects or HTTPS support entirely, and a mixed-content URL that auto-upgraded for years suddenly fails. Schedule periodic audits of http:// URLs in HTML, CSS, JS, and JSON to catch mixed-content references before they break.
Console errors for mixed content are explicit but easy to miss in a busy network panel. Filter the console by "mixed content" or "blocked" to surface them; modern Chrome DevTools has a dedicated Issues panel that aggregates the warnings.
Form submissions to http:// from an https:// page can trigger browser warnings, and the Mixed Content specification allows browsers to treat them as blockable. The pattern of having a contact form post to a different (HTTP) backend was once acceptable; today Chromium interrupts the submission with a full-page warning, and the specification leaves the warning behavior to each browser.
Subresource Integrity (SRI)
When you load a script or stylesheet from a third-party CDN, Subresource Integrity protects against a compromised CDN serving altered code (the hash in this example is a placeholder, not the hash of a real file):
<script
src="https://cdn.example.com/lib.js"
integrity="sha384-Bh3wL1jsi5e8w9K8Q4Z5xY3Z9W8h6w1X3z9V8u7K6w0Y3X2Q4Z5xY3Z9W8h6w1X3"
crossorigin="anonymous">
</script>The integrity attribute provides the script's hash; the browser verifies the hash before execution. If the hash does not match, the engine refuses to load the script. A compromised CDN serving altered code produces a SRI failure rather than executing the altered code on every visitor's machine.
Use SHA-256, SHA-384, or SHA-512 as the hash algorithm. SHA-384 is a common choice — the SRI specification's own examples and MDN's OpenSSL example use it. Generate the hash with openssl:
openssl dgst -sha384 -binary lib.js | openssl base64 -AOr use srihash.org to generate the integrity string for a remote URL.
In HTML, SRI applies only to <script> and to <link> with rel="stylesheet", "preload" or "modulepreload". It is not currently supported on <iframe>, <img>, or other elements. For images and iframes, other controls fill the gap instead, such as content-addressed URLs (a hash in the path) and Content-Security-Policy directives.
The crossorigin attribute is required for SRI on cross-origin requests. The browser needs to know that it is allowed to read the response body to compute the hash; without crossorigin, the response is opaque and SRI cannot verify it. crossorigin="anonymous" is the correct value for a public CDN; crossorigin="use-credentials" is for authenticated cross-origin requests.
Hash rotation is the main operational concern. When the upstream version of a script changes, its hash changes, and the integrity attribute must be updated. Immutable hashed URLs (lib.1234abcd.js) make rotation manageable — the URL never changes for a given hash, so the integrity attribute is stable for as long as the URL is referenced.
Modern HTTPS configuration
Four pieces make up a 2026-correct HTTPS configuration — HSTS, HTTP/3, automated certificate issuance and renewal, and Certificate Transparency — plus an optional fifth, the HSTS preload list, which hstspreload.org itself does not recommend (as of October 2026).
HSTS (HTTP Strict Transport Security) forces the browser to use HTTPS for the domain (and, with includeSubDomains, its subdomains) for the specified max-age, preventing http:// downgrade attacks. A header that also meets the preload-list requirements:
Strict-Transport-Security: max-age=63072000; includeSubDomains; preloadmax-age=63072000 is two years, the value used in hstspreload.org's example (the list requires at least one year). includeSubDomains extends the policy to every subdomain. preload signals that the domain requests inclusion in the HSTS preload list (the domain must still be submitted at hstspreload.org) — a hard-coded list shipped in Chromium / Firefox / Safari that forces HTTPS for the domain even on the user's first visit, before any header has been seen.
Decide first whether to preload at all. hstspreload.org states that while HSTS is recommended, HSTS preloading is not: many browsers, such as Chrome and Safari, automatically upgrade HTTP navigations to HTTPS regardless of a domain's HSTS policy, and preloading only adds value when those upgrades fail in the presence of an active attacker. Submission to the HSTS preload list is one-way for practical purposes. Once a domain is on the list, removing it requires waiting for a new browser release that drops the domain from the list, which can take a long time. Verify your HTTPS configuration is solid before submitting; the safety check at hstspreload.org enforces a few prerequisites.
HTTP/3 over QUIC is widely available on modern CDNs. HTTP/3 provides multiplexing without TCP-level head-of-line blocking (a stream that suffers packet loss does not prevent progress on other streams, although header compression can still cause some head-of-line blocking) and faster connection establishment (0-RTT for resumed sessions). Major CDNs — Cloudflare, Fastly, CloudFront, Akamai — support HTTP/3, though on several it is a setting you must turn on (as of October 2026, per vendor documentation). Verify with curl --http3 -I https://example.com or by inspecting a request's protocol in DevTools.
Certificate automation via Let's Encrypt and ACME clients (certbot, Caddy, Traefik, acme.sh) is the operational baseline. Manual certificate management is a slow-motion outage waiting to happen — expired certificates produce a hard browser block that no one notices until customer reports arrive. Automated renewal with monitoring is non-negotiable in 2026.
Certificate Transparency logging is surfaced through the certificate authority and the CDN's TLS configuration. As of October 2026 all three engines enforce it: Chrome, Apple platforms (including Safari), and Firefox from version 135 (February 2025) on desktop — certificates without sufficient CT evidence fail the TLS connection. Publicly trusted CAs can embed the required timestamps in the certificate; verify in CI by checking the issued certificate against the crt.sh Certificate Transparency search.
OCSP stapling is no longer a default recommendation. Let's Encrypt shut down its OCSP service in August 2025 and now publishes revocation information only through certificate revocation lists, so its certificates no longer carry an OCSP URL to staple. Keep stapling enabled only where your CA still operates OCSP, and make sure a stapling configuration left over from an older setup does not produce errors when the certificate has no OCSP URL.
Audit findings that commonly trip teams up
Six recurring findings appear in HTTPS audits.
Staging environments still on http:// are a frequent finding. Features that work in production silently break in staging because staging is not a Secure Context. Standardize all environments — local, staging, preview, production — on HTTPS. Modern dev-tooling makes this cheap (mkcert for local, ACME for staging).
Embedded http:// images, fonts, or analytics scripts in templates that have not been audited since the original HTTPS migration. Auto-upgrade hides the images until the upstream stops serving HTTPS; fonts and scripts are blockable content, so they fail outright. Schedule a recurring grep through HTML, CSS, JS, and JSON for http:// and replace with https:// or remove.
Third-party iframes that load over http://. Active mixed content blocks them outright; the parent has no error visibility unless monitoring the console. Catch these in CI by parsing rendered HTML for http:// src and href values.
Service Worker registration attempted from a context that is not secure, or pointed at a script or scope on another origin. navigator.serviceWorker.register() requires a secure context, and the script URL and scope must be same-origin with the registering page, so on an http:// staging host navigator.serviceWorker is undefined and the call throws, while a registration that references an http:// or cross-origin script URL rejects with a SecurityError that nobody sees unless the promise rejection is logged. Register the Service Worker from an HTTPS page with a same-origin script and scope, and log registration failures.
WebSocket URLs hardcoded as ws:// instead of wss://. Fails on https:// pages because ws:// is active mixed content and is blocked outright. Use wss:// exclusively in 2026.
Mixed-content auto-upgrade success rate dropping over time as upstreams retire HTTP. The audit pattern that catches this is the recurring crawl for http:// references plus client-side error monitoring for failed resource loads, reviewed periodically.
Verification priorities for the next planning cycle
- Run a site-wide crawl for
http://URLs in HTML, CSS, JS, and JSON; replace withhttps://or remove - Add HSTS with the
includeSubDomainsdirective if you have not; addpreloadand submit to the preload list only if you accept that removal is slow and that hstspreload.org does not recommend preloading - Add SRI to every external script and stylesheet you do not control; document the hash-rotation process for each dependency
- Verify HTTP/3 is enabled at your CDN; test with
curl --http3 -I https://your-domain.comor an HTTP/3 status check - Audit SecureContext API usage in code — if any feature is gated behind
isSecureContext, log a warning whenisSecureContextisfalseto catch staging drift - Configure
Content-Security-Policy: upgrade-insecure-requestsas a defense-in-depth layer for legacy mixed content during cleanup; remove it once the cleanup completes