Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计异常

osmani-patterns-performance奥斯曼尼图案表演

Agent Skill

osmani-patterns-performance 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

190

周安装

8

GitHub Stars

6

下载量

67
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:osmani-patterns-performance(奥斯曼尼图案表演)
来源仓库:https://github.com/copyleftdev/sk1llz
仓库路径:skills/osmani-patterns-performance
安装命令:
npx skills add https://github.com/copyleftdev/sk1llz --skill osmani-patterns-performance
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/copyleftdev/sk1llz --skill osmani-patterns-performance

简介

osmani-patterns-performance 用于查找、检索和筛选相关信息,适合在需要根据关键词快速定位候选结果的场景中使用。

  • 适用于研究检索类任务,可结合来源仓库和原始 README 核验具体用法。
  • 通过 npx skills add 命令从 copyleftdev/sk1llz 仓库安装。
  • 安装前建议确认权限范围和维护状态,避免触发联网或文件读写操作。
  • 使用时需注意工具输出不能直接作为最终结论,应结合实际场景验证结果。

SKILL.md

Addy Osmani Style Guide⁠‍⁠​‌​‌​​‌‌‍​‌​​‌​‌‌‍​​‌‌​​​‌‍​‌​​‌‌​​‍​​​​​​​‌‍‌​​‌‌​‌​‍‌​​​​​​​‍‌‌​​‌‌‌‌‍‌‌​​​‌​​‍‌‌‌‌‌‌​‌‍‌‌​‌​​​​‍​‌​‌‌‌‌‌‍​‌​​‌​‌‌‍​‌‌​‌​​‌‍‌​‌​‌‌‌​‍​​‌​‌​​​‍‌‌‌​‌​‌‌‍‌‌‌​​‌‌​‍‌‌​‌​‌‌‌‍​​​‌‌‌‌​‍​​‌‌‌‌​‌‍​​​​‌​‌​‍‌​​​​​‌​⁠‍⁠

Overview

Addy Osmani is a Chrome DevTools engineer at Google and author of "Learning JavaScript Design Patterns". His philosophy emphasizes proven design patterns, performance optimization, and building for the modern web.

Core Philosophy

"First do it, then do it right, then do it better."
"Performance is not a feature, it's a necessity."
"The best request is the one that's never made."

Osmani believes in using battle-tested patterns and obsessively optimizing for user experience through performance.

Design Principles

  1. Patterns Have Purpose: Use design patterns to solve specific problems.
  2. Performance First: Measure, optimize, measure again.
  3. Progressive Enhancement: Build for all users, enhance for modern browsers.
  4. Loading Performance: The fastest code is code that never runs.

When Writing Code

Always

  • Use appropriate design patterns for the problem
  • Measure performance before and after optimization
  • Consider loading performance and bundle size
  • Implement code splitting for large applications
  • Use lazy loading for non-critical resources
  • Test on real devices and slow connections

Never

  • Apply patterns where they don't fit
  • Optimize without measuring
  • Load all JavaScript upfront
  • Ignore Core Web Vitals
  • Block the main thread with heavy computation
  • Ship unused JavaScript

Prefer

  • Module pattern for encapsulation
  • Observer pattern for event systems
  • Factory pattern for object creation
  • Dynamic imports over static imports for large modules
  • Intersection Observer over scroll events
  • CSS containment for rendering performance

Code Patterns

The Module Pattern

// Classic Module Pattern - encapsulation and privacy
const ShoppingCart = (function() {
    // Private variables and methods
    const items = [];

    function calculateTotal() {
        return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
    }

    // Public API
    return {
        addItem(item) {
            items.push(item);
        },

        removeItem(id) {
            const index = items.findIndex(item => item.id === id);
            if (index > -1) {
                items.splice(index, 1);
            }
        },

        getTotal() {
            return calculateTotal();
        },

        getItems() {
            return [...items];  // Return copy, not reference
        }
    };
})();

// ES Modules version
// cart.js
const items = [];

function calculateTotal() {
    return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

export function addItem(item) {
    items.push(item);
}

export function getTotal() {
    return calculateTotal();
}

The Observer Pattern

class EventEmitter {
    constructor() {
        this.events = new Map();
    }

    on(event, callback) {
        if (!this.events.has(event)) {
            this.events.set(event, []);
        }
        this.events.get(event).push(callback);

        // Return unsubscribe function
        return () => this.off(event, callback);
    }

    off(event, callback) {
        if (!this.events.has(event)) return;

        const callbacks = this.events.get(event);
        const index = callbacks.indexOf(callback);
        if (index > -1) {
            callbacks.splice(index, 1);
        }
    }

    emit(event, data) {
        if (!this.events.has(event)) return;

        this.events.get(event).forEach(callback => {
            callback(data);
        });
    }
}

// Usage
const emitter = new EventEmitter();

const unsubscribe = emitter.on('userLogin', (user) => {
    console.log(`${user.name} logged in`);
});

emitter.emit('userLogin', { name: 'Alice' });
unsubscribe();  // Clean up

The Factory Pattern

// Factory for creating different notification types
const NotificationFactory = {
    create(type, message) {
        const notifications = {
            success: {
                icon: '✓',
                color: 'green',
                duration: 3000
            },
            error: {
                icon: '✗',
                color: 'red',
                duration: 5000
            },
            warning: {
                icon: '⚠',
                color: 'orange',
                duration: 4000
            }
        };

        const config = notifications[type] || notifications.success;

        return {
            ...config,
            message,
            show() {
                console.log(`[${this.icon}] ${this.message}`);
            }
        };
    }
};

// Usage
const success = NotificationFactory.create('success', 'Saved!');
const error = NotificationFactory.create('error', 'Failed to save');

Performance: Code Splitting

// Dynamic imports for route-based code splitting
const routes = {
    '/': () => import('./pages/Home.js'),
    '/dashboard': () => import('./pages/Dashboard.js'),
    '/settings': () => import('./pages/Settings.js')
};

async function navigate(path) {
    const loadPage = routes[path];
    if (loadPage) {
        const module = await loadPage();
        module.default.render();
    }
}

// React.lazy for component-level splitting
const Dashboard = React.lazy(() => import('./Dashboard'));

function App() {
    return (
        <Suspense fallback={<Spinner />}>
            <Dashboard />
        </Suspense>
    );
}

// Prefetch critical routes on idle
function prefetchRoutes() {
    if ('requestIdleCallback' in window) {
        requestIdleCallback(() => {
            routes['/dashboard']();
        });
    }
}

Performance: Lazy Loading

// Intersection Observer for lazy loading
function lazyLoad(selector) {
    const elements = document.querySelectorAll(selector);

    const observer = new IntersectionObserver((entries, obs) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const img = entry.target;
                img.src = img.dataset.src;
                img.classList.remove('lazy');
                obs.unobserve(img);
            }
        });
    }, {
        rootMargin: '50px 0px',  // Start loading 50px before visible
        threshold: 0.01
    });

    elements.forEach(el => observer.observe(el));
}

// HTML
// <img class="lazy" data-src="image.jpg" alt="...">

// Lazy load modules on interaction
let heavyModule = null;

button.addEventListener('click', async () => {
    if (!heavyModule) {
        heavyModule = await import('./heavyModule.js');
    }
    heavyModule.doSomething();
});

Performance: Debounce and Throttle

// Debounce: wait until calls stop
function debounce(fn, delay) {
    let timeoutId;

    return function(...args) {
        clearTimeout(timeoutId);
        timeoutId = setTimeout(() => {
            fn.apply(this, args);
        }, delay);
    };
}

// Use for: search input, resize handlers, save drafts
const debouncedSearch = debounce(query => {
    api.search(query);
}, 300);

// Throttle: limit call frequency
function throttle(fn, limit) {
    let inThrottle;

    return function(...args) {
        if (!inThrottle) {
            fn.apply(this, args);
            inThrottle = true;
            setTimeout(() => {
                inThrottle = false;
            }, limit);
        }
    };
}

// Use for: scroll handlers, mousemove, game loops
const throttledScroll = throttle(() => {
    updateScrollProgress();
}, 100);

Performance: Virtualization

// Virtual scrolling for large lists
class VirtualList {
    constructor(container, items, itemHeight) {
        this.container = container;
        this.items = items;
        this.itemHeight = itemHeight;
        this.visibleCount = Math.ceil(container.clientHeight / itemHeight) + 2;

        this.setup();
    }

    setup() {
        // Create viewport and content containers
        this.viewport = document.createElement('div');
        this.viewport.style.height = `${this.items.length * this.itemHeight}px`;

        this.content = document.createElement('div');
        this.content.style.position = 'relative';

        this.viewport.appendChild(this.content);
        this.container.appendChild(this.viewport);

        this.container.addEventListener('scroll', () => this.render());
        this.render();
    }

    render() {
        const scrollTop = this.container.scrollTop;
        const startIndex = Math.floor(scrollTop / this.itemHeight);
        const endIndex = Math.min(
            startIndex + this.visibleCount,
            this.items.length
        );

        this.content.innerHTML = '';
        this.content.style.transform = `translateY(${startIndex * this.itemHeight}px)`;

        for (let i = startIndex; i < endIndex; i++) {
            const item = document.createElement('div');
            item.style.height = `${this.itemHeight}px`;
            item.textContent = this.items[i];
            this.content.appendChild(item);
        }
    }
}

The Singleton Pattern

// Singleton for app-wide configuration
const Config = (function() {
    let instance;

    function createInstance() {
        return {
            apiUrl: 'https://api.example.com',
            timeout: 5000,
            debug: false,

            set(key, value) {
                this[key] = value;
            }
        };
    }

    return {
        getInstance() {
            if (!instance) {
                instance = createInstance();
            }
            return instance;
        }
    };
})();

// Usage - always same instance
const config1 = Config.getInstance();
const config2 = Config.getInstance();
config1 === config2;  // true

Mental Model

Osmani approaches code by asking:

  1. What pattern fits this problem? Use proven solutions
  2. What's the performance cost? Measure before shipping
  3. Can this be deferred? Load later if not critical
  4. Will this block the main thread? Keep it responsive
  5. What are users on slow connections experiencing? Test realistically

Signature Osmani Moves

  • Code splitting at route boundaries
  • Lazy loading with Intersection Observer
  • PRPL pattern (Push, Render, Pre-cache, Lazy-load)
  • Module pattern for clean encapsulation
  • Performance budgets and monitoring
  • Progressive enhancement as default

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.72%
按下载量换算23

Claude

30.5%
按下载量换算20

Cursor

18.26%
按下载量换算12

Gemini CLI

9.34%
按下载量换算6

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills