一键导入
frontend-performance
Optimize web application performance including loading, rendering, and interaction metrics. Improve Core Web Vitals and user experience.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Optimize web application performance including loading, rendering, and interaction metrics. Improve Core Web Vitals and user experience.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | frontend-performance |
| description | Optimize web application performance including loading, rendering, and interaction metrics. Improve Core Web Vitals and user experience. |
| triggers | ["/web performance","/performance optimize"] |
This skill covers techniques for optimizing web application performance to improve loading speed, rendering efficiency, and user experience metrics.
Use this skill when you need to:
Largest Contentful Paint (LCP)
First Input Delay (FID) / Interaction to Next Paint (INP)
Cumulative Layout Shift (CLS)
Resource Optimization
// Lazy load non-critical resources
const image = new Image();
image.loading = 'lazy';
image.src = '/large-image.jpg';
// Preload critical resources
<link rel="preload" href="/critical.css" as="style">
<link rel="preconnect" href="https://api.example.com">
// Prefetch next page resources
<link rel="prefetch" href="/next-page.js">
Code Splitting
// React lazy loading
const HeavyComponent = React.lazy(() => import('./HeavyComponent'));
// Route-based splitting
const routes = {
'/dashboard': () => import('./pages/Dashboard'),
'/profile': () => import('./pages/Profile'),
};
// Dynamic imports
async function loadFeature() {
const feature = await import('./feature');
feature.init();
}
Bundle Optimization
// webpack.config.js
module.exports = {
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
};
CSS Optimization
/* Contain paint for isolated sections */
.card {
contain: layout style paint;
}
/* Use transform for animations */
.animated {
will-change: transform;
transform: translateZ(0);
}
/* Avoid layout thrashing */
/* ❌ Bad: Read then write repeatedly */
const height = element.offsetHeight;
element.style.height = (height + 10) + 'px';
/* ✅ Good: Batch reads and writes */
const height = element.offsetHeight;
requestAnimationFrame(() => {
element.style.height = (height + 10) + 'px';
});
JavaScript Optimization
// Debounce expensive operations
const debouncedSearch = debounce((query) => {
performSearch(query);
}, 300);
// Use requestIdleCallback for non-critical work
requestIdleCallback(() => {
analytics.track('page_view');
});
// Virtualize long lists
import { FixedSizeList } from 'react-window';
<FixedSizeList
height={500}
itemCount={10000}
itemSize={50}
>
{Row}
</FixedSizeList>
Web Workers
// Offload heavy computations
const worker = new Worker('worker.js');
worker.postMessage({ data: largeDataset });
worker.onmessage = (e) => {
displayResults(e.data);
};
Modern Formats
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Description" width="800" height="600">
</picture>
Responsive Images
<img
srcset="small.jpg 300w, medium.jpg 600w, large.jpg 900w"
sizes="(max-width: 600px) 300px, (max-width: 900px) 600px, 900px"
src="large.jpg"
alt="Description"
>
SVG Optimization
Service Worker
// Cache-first strategy
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
})
);
});
// Stale-while-revalidate for API calls
const staleWhileRevalidate = new workbox.strategies.StaleWhileRevalidate({
cacheName: 'api-cache',
});
workbox.routing.registerRoute(
({url}) => url.pathname.startsWith('/api/'),
staleWhileRevalidate
);
HTTP Caching
Cache-Control: public, max-age=31536000, immutable # Static assets
Cache-Control: no-cache # Dynamic content
Cache-Control: stale-while-revalidate=86400 # Freshness + background update
Lighthouse CI
// lighthouserc.js
module.exports = {
ci: {
collect: {
url: ['http://localhost:3000/'],
numberOfRuns: 3,
},
assert: {
assertions: {
'categories:performance': ['error', { minScore: 0.9 }],
'first-contentful-paint': ['error', { maxNumericValue: 2000 }],
},
},
},
};
Real User Monitoring
// Send Core Web Vitals to analytics
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
function sendToAnalytics(metric) {
analytics.track('web_vitals', {
name: metric.name,
value: metric.value,
id: metric.id,
});
}
getCLS(sendToAnalytics);
getFID(sendToAnalytics);
getLCP(sendToAnalytics);
See the examples/ directory for:
webpack-config/ - Optimized webpack configurationsimage-optimization/ - Image loading strategiesservice-worker/ - Caching implementationsperformance-budget.json - Performance budget configurationInteractive onboarding workflow that interviews users to understand their coding goals and generates PR-ready implementation plans. Use when starting a new development task to ensure clear requirements and structured execution.
Implement security best practices for Gamma integration. Use when securing API keys, implementing access controls, or auditing Gamma security configuration. Trigger with phrases like "gamma security", "gamma API key security", "gamma secure", "gamma credentials", "gamma access control".
Write effective technical documentation including READMEs, API docs, architecture decisions, and inline code documentation.
Build and manage CI/CD pipelines with Azure DevOps. Configure builds, releases, and automate software delivery workflows.
Develop, deploy, and manage Azure Functions for serverless computing. Supports HTTP triggers, timers, queues, and event-driven architectures.
Manage Azure resources effectively using CLI, Portal, Bicep, and ARM templates. Use for provisioning, organizing, and maintaining cloud infrastructure.