v1.3 · 0 deps · TypeScript · Apache 2.0

Your iframes crash phones.
We fix that.

Smart memory management for heavy WebGL and game iframes. Auto-detects devices, manages memory zones, prevents Safari from killing your page.

npm i iframe-shield
0Modules
0Device tiers
0Memory zones
0Dependencies

Before vs After

Real scenarios. Real devices. Real pain — eliminated.

Scenario
Without iframe-shield
With iframe-shield
iPhone 12 — game + payment
Tab killed. White screen. Progress lost.
Payment opens safely. Game untouched.
iPhone 15 — switch to Messages
Background tab killed in 3 seconds.
Auto-freeze. Resume on return.
iPad — 2 games on page
Second iframe crashes entire tab.
1 active, 1 frozen. Swap on tap.
Android low-end — 600MB game
5fps. Janky. Eventually OOM.
Auto quality reduction. Smooth.
Desktop Chrome
Works fine.
Detects desktop. Zero overhead.

Without protection

600MB iframe fills the budget. Any additional operation crashes the tab. Payment modals, chat widgets, tab switching — all fatal.

With iframe-shield

Memory managed continuously. Device-aware budgets prevent overcommit. Quality degrades gracefully. Crashes auto-recover.

Features

Every layer works independently. If one misses, the next catches it.

Device Profiling

Auto-detects 6 tiers. Optimal budgets per device class.

Memory Zones

5 graduated zones. Proportional response to pressure.

Game Proxy

Same-origin proxy for full resource control.

iOS Safari Shield

Jetsam prevention. Background freeze. Tab recovery.

Crash Recovery

Auto-restart at lower quality. Progressive degradation.

Graduated Freeze

4 levels. Light pause to full destruction. Resume any.

Quality Control

4 levels. 30s user-lock. Auto or manual.

Debug Overlay

Shadow DOM debugger. Memory bar. Event log.

Network Budget

Track bytes per domain. Auto-act on limits.

Memory Logging

500-entry buffer. Timestamped. Exportable.

Lazy Loading

IntersectionObserver. Load on entry. Freeze on exit.

React Hook

useIframeShield() — drop-in with full API.

Memory zones

Proportional response. Not too aggressive. Not too late.

GREEN
YELLOW
RED
CRIT
!
ZoneUtilizationResponse
Green0 – 60%Normal operation
Yellow60 – 75%Quality steps down
Red75 – 85%Non-visible iframes frozen
Critical85 – 95%Single iframe, minimal quality
Emergency95%+Destroy low-priority iframes

Device-aware

deviceProfile: 'auto'

DeviceBudgetStrategy
iPhone SE / older Android600 MBAggressive
iPhone 12-15800 MBBalanced
iPhone 16 Pro / flagship1000 MBRelaxed
iPad1000 MBRelaxed
Laptop / Desktop1500 MBMinimal
Gaming PC2500 MBMonitor only

Quick start

import { useIframeShield } from 'iframe-shield/react';

function Game({ url }) {
  const { iframeRef } = useIframeShield({
    src: url,
    estimatedMemoryMB: 700,
    config: { quality: 'auto', crashRecovery: { enabled: true } },
  });
  return <iframe ref={iframeRef} src={url} />;
}