import-on-interaction

Defer non-critical modules until user interactions using dynamic import().

235|25|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/PatternsDev/skills --skill import-on-interaction
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: import-on-interaction
Source: https://github.com/PatternsDev/skills/tree/main/javascript/import-on-interaction
Command: npx skills add https://github.com/PatternsDev/skills --skill import-on-interaction

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps optimize web performance by deferring non-critical code until user interaction, reducing initial load times and improving Time to Interactive (TTI) and First Input Delay (FID).

Core Features & Use Cases

  • Lazy-load heavy UI components on first user interaction (clicks, hovers, or form inputs).
  • Use dynamic import() to fetch modules on demand.
  • Provide facades or lightweight placeholders to preserve UX while loading heavyweight dependencies.

Quick Start

Trigger a user interaction (click or hover) to load a heavy module on demand using dynamic import.

Frequently Asked Questions about import-on-interaction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I lazy-load heavy JavaScript modules on user interaction?

Lazy-load heavy JavaScript modules on user interaction by using the dynamic import() pattern to fetch code on demand during events like clicks or hovers. This defers non-critical loading until needed, reducing initial load times.

What is the best way to improve Time to Interactive when using heavy UI components?

The best way to improve Time to Interactive is to defer non-critical UI components using facades or lightweight placeholders. By loading heavyweight dependencies only on interaction, you reduce initial load times and improve First Input Delay.

Can I use dynamic import() to load third-party widgets on demand in React or Vue?

Yes, you can use dynamic import() to load third-party widgets on demand in React or Vue. Framework-aware strategies allow you to fetch non-critical widgets during user interactions, preserving initial load performance without blocking the UI.

How do facades help with web performance when deferring non-critical code?

Facades help web performance by providing lightweight placeholders that preserve user experience while heavyweight dependencies load in the background. They visually represent deferred non-critical code until a user interaction triggers the dynamic import.

When should I not use import-on-interaction for lazy-loading?

You should not use import-on-interaction for lazy-loading critical modules required during initial page load. This approach is strictly for non-critical code, heavy libraries, and third-party widgets that can be deferred without degrading core user experience.