import-on-interaction

Defer non-critical JavaScript loading until user interaction triggers it.

Updated Mar 27, 2026
One-click install
npx skills add https://github.com/quanngynx/GDGO-2026.Servexa-Warranty-AI --skill import-on-interaction-quanngynx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: import-on-interaction
Source: https://github.com/quanngynx/GDGO-2026.Servexa-Warranty-AI/tree/main/servexa-warranty-ai/.agents/skills/import-on-interaction
Command: npx skills add https://github.com/quanngynx/GDGO-2026.Servexa-Warranty-AI --skill import-on-interaction-quanngynx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents non-critical, heavy JavaScript from blocking the main thread during initial page load, improving responsiveness once users actually try to interact.

Core Features & Use Cases

  • Dynamic on-interaction loading: Load feature code only after a user gesture (click, hover, focus) triggers the need for that functionality.
  • Facades for third-party embeds: Show a lightweight placeholder UI and fetch the real embed only when the user proceeds, reducing initial payload and processing cost.
  • Progressive loading guidance: Apply trade-offs and measurement tips to avoid jarring delays after interaction, using approaches like idle-time loading and preconnect/prefetch where appropriate.
  • Framework patterns: Use dynamic import() for vanilla JS and React.lazy/Suspense for React component-level deferral.

Quick Start

Ask an AI to propose where to replace eager imports with dynamic on-interaction loading and facades for a specific non-critical widget in your app, including example event triggers (click/hover) and loading-state behavior.

Frequently Asked Questions about import-on-interaction

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

FAQPage Schema
How do I defer loading heavy third-party widgets until user interaction?

Defer loading heavy third-party widgets by using dynamic import() or React.lazy/Suspense to fetch code only after a user gesture like click, hover, or focus triggers the need, reducing initial payload and main thread blocking.

How do facades for third-party embeds improve web vitals?

Facades for third-party embeds improve web vitals by displaying a lightweight placeholder UI instead of the heavy embed, fetching the real resource only upon user interaction to reduce initial JavaScript processing cost and improve FID and TTI.

Does React Suspense work with dynamic import for lazy loading components?

React Suspense works with dynamic import by using React.lazy for component-level deferral, allowing you to wrap dynamically imported components and show loading states until the non-critical feature code finishes fetching after interaction.

What is the best way to lazy load non-critical JavaScript without delaying functionality?

The best way to lazy load non-critical JavaScript without jarring delays is combining on-interaction loading with progressive loading guidance, using idle-time loading, preconnect, and prefetch strategies to prepare resources before the user gesture occurs.

When should I not use on-interaction dynamic imports?

You should not use on-interaction dynamic imports for critical above-the-fold features where delayed functionality after interaction would harm user experience, as the trade-off sacrifices immediate readiness for improved initial page load performance.