Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 4 min read

I Built an APM for Angular That Runs Entirely in Your Browser

Every Angular Developer Asks This "Why is my page taking 8 seconds to load?" "Which component is re-rendering 30 times?" "Is this API call redundant?" "Why did this click freeze the UI?" Angular DevTools shows you c

I Built an APM for Angular That Runs Entirely in Your Browser

Every Angular Developer Asks This

Every Angular developer asks...

"Why is my page taking 8 seconds to load?"
"Which component is re-rendering 30 times?"
"Is this API call redundant?"
"Why did this click freeze the UI?"

Angular DevTools shows you components. ngLens shows you the WHY.

What is ngLens?

ngLens β€” See what Angular doesn't show you

ngLens is a Chrome DevTools extension that acts as an Execution Intelligence Platform for Angular. Think APM β€” but it runs entirely in your browser, requires zero configuration, and never sends data anywhere.

  • Works with Angular 14–22
  • Performance overhead: < 3% CPU
  • Setup: Install β†’ Open DevTools β†’ Done

How It's Different

ngLens vs Angular DevTools

Angular DevTools gives you a component tree. ngLens gives you:

Feature Angular DevTools ngLens
Component tree βœ“ βœ“
WHY it rendered βœ— βœ“
Waterfall timeline βœ— βœ“
API β†’ Store β†’ Component chain βœ— βœ“
Memory leak detection βœ— βœ“
Impact scoring βœ— βœ“
Targeted fix per component βœ— βœ“
Signal tracking (computed, input) βœ— βœ“
Duplicate API detection βœ— βœ“
Jank detection (frame drops) βœ— βœ“

Your App's Health at a Glance

Overview Tab β€” health at a glance

Open ngLens, and in seconds you see:

  • Risk score (0–100) per component
  • Top issue with root cause
  • Suggested fix with expected gain
  • Memory risks flagged immediately
  • Environment detection (production/dev mode)

No digging through flame graphs. No guessing.

Execution Explorer β€” See WHEN Things Happened

Execution Explorer waterfall timeline

A horizontal waterfall timeline β€” like Chrome's Network tab, but for your Angular app's internal execution flow.

See exactly:

  • When each component rendered relative to others
  • Which API call is the bottleneck (highlighted automatically)
  • How long each operation actually took
  • The critical path through your app's execution

In the example above, POST /api/orders/search takes 4.67s β€” that's 55% of total time. You'd know exactly where to optimize.

Render Inspector β€” Component Cascade + Data Flow

Render Inspector β€” Component Cascade

See which components rendered, how many times, and trace the data flow:

  • Component Cascade β€” Ranked by render count and time cost
  • Data Flow β€” Which API/store action triggered each render
  • Hotspot indicator β€” The worst offender highlighted immediately
  • Action-level breakdown β€” Click, Change, Input events separated

Causal Chains β€” Which API Affected Which Component

Causal chains β€” API to component mapping

This is the feature that saves hours of debugging:

GET /api/users β†’ 200 β†’ [AUTH] SET_USER β†’ 3 components
POST /api/orders/search β†’ 200 β†’ [ORDERS] SET_LIST β†’ 5 components
GET /api/notifications β†’ 200 β†’ [NOTIFY] UPDATE β†’ (duplicate flagged!)
[FILTERS] SET_ACTIVE β†’ [FILTERS] SET_RESULTS +2

ngLens automatically:

  • Links API calls to store actions to component renders
  • Flags duplicate APIs
  • Counts impacted components per action

Detect Leaks. Get Actionable Fixes.

Memory leaks and recommendations

Memory Leaks detected:

  • UserService.notifications$ β€” Subscribed in DashboardComponent, never unsubscribed after destroy β†’ Fix: takeUntilDestroyed()
  • setInterval in PollingService β€” Created every 5s, never cleared β†’ Fix: clearInterval in ngOnDestroy()

Recommendations prioritized by impact:

  • πŸ”΄ HIGH β€” Add OnPush to DataGridComponent (saves ~300ms per interaction)
  • 🟑 MED β€” Add trackBy to OrderListComponent (50 items re-created every update)
  • 🟒 LOW β€” Zone pollution: WebSocket in ChatService β†’ Move to runOutsideAngular()

Full Signal Reactivity Tracking

Signal tracking β€” Angular 17-22

ngLens captures the full signal chain across Angular versions:

  • Angular ≀ 16 β€” RxJS subjects, HTTP, timers, Router
  • Angular 17+ β€” computed() recomputation, input() signals
  • Angular 19+ β€” linkedSignal(), resource(), httpResource()
  • Angular 22 β€” Signal Forms, @Service(), all stable signal APIs

Example traced chain:

UserService.currentUser.set({name: "John"})
  β†’ DashboardComponent.greeting (computed) β†’ "Hello, John"
    β†’ DashboardComponent rendered

Hotspots + Compare Runs

Hotspots and Compare Runs

Save a baseline β†’ Make your fix β†’ Capture again β†’ See the improvement instantly.

Metric Before After Change
Render count 156 42 -73%
Avg render cost 4.2ms 1.8ms -57%
Render frequency 4.2x 1.1x -74%
Memory risks 2 0 Fixed

Privacy & Security

This was non-negotiable from day one:

  • βœ… All analysis runs locally in your browser
  • βœ… Source code and results never leave your machine
  • βœ… Minimal permissions β€” only activeTab, scripting, tabs, storage
  • βœ… Strict Content Security Policy
  • βœ… Optional analytics require explicit opt-in
  • βœ… MIT License β€” fully open source and auditable

Get Started

Install from Chrome Web Store:
πŸ”— Install ngLens

Or build from source:

git clone https://github.com/patch-work-book/nglens.git
cd nglens
npm install
npm run build
# Load dist/ as unpacked extension in chrome://extensions

ngLens

Find Angular performance problems and learn how to fix them.

ngLens is a Chrome Extension that analyzes Angular applications at runtime, identifies performance issues, and teaches you how to fix them β€” whether you're a junior developer learning Angular or a senior architect optimizing at scale.

Features (V1)

  • Angular Compatibility β€” Runtime tracking supports Angular 17-21; Angular 21 has a dedicated smoke check
  • Angular Detection β€” Automatically detects Angular apps in both development and production mode
  • Change Detection Analysis β€” Flags Default change detection, missing OnPush, and *ngFor without trackBy
  • Unnecessary Re-render Detection β€” Identifies excessive DOM mutation frequency, render bottlenecks, and template anti-patterns
  • Memory Cleanup Risk Detection β€” Flags possible surviving subscriptions, unmanaged timers, and DOM listeners
  • RxJS Subscription Cleanup Detector β€” Detects subscriptions without observed cleanup and recommends takeUntil, takeUntilDestroyed, or async pipe usage
  • Bundle/Lazy-loading Guidance β€” Highlights initial load risk areas and lazy…

What's Next

  • V2: CD profiler, Zone.js profiler, FPS monitor, interaction latency
  • V3: Architecture smells, regression detection, Signals migration assistant

Angular DevTools shows you components. ngLens shows you the why.

Give it 30 seconds. That's all it needs.

Found a bug or have feedback? Open an issue β€” I read every one.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.