wp-performance

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WordPress Performance Optimization

WordPress性能优化

Complete guide for optimizing WordPress site performance, Core Web Vitals, and passing speed tests.
这是一份完整的WordPress网站性能优化指南,涵盖Core Web Vitals优化及速度测试达标方法。

Core Web Vitals Targets

Core Web Vitals 指标目标

MetricGoodNeeds ImprovementPoor
LCP (Largest Contentful Paint)≤2.5s2.5-4s>4s
INP (Interaction to Next Paint)≤200ms200-500ms>500ms
CLS (Cumulative Layout Shift)≤0.10.1-0.25>0.25

指标优秀待改进较差
LCP (Largest Contentful Paint)≤2.5s2.5-4s>4s
INP (Interaction to Next Paint)≤200ms200-500ms>500ms
CLS (Cumulative Layout Shift)≤0.10.1-0.25>0.25

Image Optimization

图片优化

Plugin Stack

推荐插件栈

  1. EWWW Image Optimizer - Best all-around
    • Lossless & lossy compression
    • WebP conversion
    • Lazy loading
    • CDN option (ExactDN)
  2. ShortPixel - Alternative with more formats
    • AVIF support
    • Glossy/lossy/lossless modes
    • Bulk optimization
  3. Imagify - Simple and effective
    • Three compression levels
    • WebP conversion
    • Resize on upload
  1. EWWW Image Optimizer - 综合表现最佳
    • 无损/有损压缩
    • WebP格式转换
    • 懒加载
    • CDN选项(ExactDN)
  2. ShortPixel - 支持更多格式的替代选择
    • 支持AVIF格式
    • 光泽/有损/无损三种模式
    • 批量优化
  3. Imagify - 简单高效
    • 三种压缩级别
    • WebP格式转换
    • 上传时自动调整尺寸

EWWW Configuration

EWWW 配置示例

php
// Recommended EWWW settings via wp-config.php or plugin settings

// Enable WebP conversion
define('EWWW_IMAGE_OPTIMIZER_WEBP', true);

// Set maximum dimensions
define('EWWW_IMAGE_OPTIMIZER_MAX_WIDTH', 2560);
define('EWWW_IMAGE_OPTIMIZER_MAX_HEIGHT', 2560);

// Enable lazy loading
define('EWWW_IMAGE_OPTIMIZER_LAZY_LOAD', true);
php
// Recommended EWWW settings via wp-config.php or plugin settings

// Enable WebP conversion
define('EWWW_IMAGE_OPTIMIZER_WEBP', true);

// Set maximum dimensions
define('EWWW_IMAGE_OPTIMIZER_MAX_WIDTH', 2560);
define('EWWW_IMAGE_OPTIMIZER_MAX_HEIGHT', 2560);

// Enable lazy loading
define('EWWW_IMAGE_OPTIMIZER_LAZY_LOAD', true);

Manual Image Guidelines

手动图片处理规范

Use CaseFormatMax WidthQuality
Hero imagesWebP (fallback JPG)1920px80-85%
Content imagesWebP (fallback JPG)1200px80%
ThumbnailsWebP600px75%
Icons/logosSVG or PNGAs neededLossless
Photos with transparencyWebP or PNGAs needed85%
使用场景格式最大宽度质量
首页横幅图WebP(降级兼容JPG)1920px80-85%
内容配图WebP(降级兼容JPG)1200px80%
缩略图WebP600px75%
图标/LogoSVG或PNG按需设置无损
带透明度的图片WebP或PNG按需设置85%

Responsive Images

响应式图片

WordPress generates srcset automatically. Ensure proper sizes:
php
// Add custom image sizes
function theme_custom_image_sizes() {
    add_image_size('hero', 1920, 1080, true);
    add_image_size('hero-tablet', 1024, 768, true);
    add_image_size('hero-mobile', 768, 1024, true);
    add_image_size('card', 600, 400, true);
    add_image_size('thumb-square', 300, 300, true);
}
add_action('after_setup_theme', 'theme_custom_image_sizes');
WordPress会自动生成srcset,确保配置合适的尺寸:
php
// Add custom image sizes
function theme_custom_image_sizes() {
    add_image_size('hero', 1920, 1080, true);
    add_image_size('hero-tablet', 1024, 768, true);
    add_image_size('hero-mobile', 768, 1024, true);
    add_image_size('card', 600, 400, true);
    add_image_size('thumb-square', 300, 300, true);
}
add_action('after_setup_theme', 'theme_custom_image_sizes');

Preload Critical Images

预加载关键图片

php
// Preload LCP image
function theme_preload_hero() {
    if (is_front_page()) {
        $hero_url = get_theme_file_uri('/assets/images/hero.webp');
        echo '<link rel="preload" as="image" href="' . esc_url($hero_url) . '">';
    }
}
add_action('wp_head', 'theme_preload_hero', 1);

php
// Preload LCP image
function theme_preload_hero() {
    if (is_front_page()) {
        $hero_url = get_theme_file_uri('/assets/images/hero.webp');
        echo '<link rel="preload" as="image" href="' . esc_url($hero_url) . '">';
    }
}
add_action('wp_head', 'theme_preload_hero', 1);

Video Optimization

视频优化

Self-Hosted Video

自托管视频

  1. Compress before upload
    • Use HandBrake or FFmpeg
    • Target: 1-2 MB per minute for web
    • Resolution: 1080p max (720p for backgrounds)
    • Codec: H.264 (MP4) for compatibility, H.265 for smaller size
  2. FFmpeg commands
bash
undefined
  1. 上传前先压缩
    • 使用HandBrake或FFmpeg工具
    • 目标:网页视频每分钟1-2 MB
    • 分辨率:最高1080p(背景视频用720p)
    • 编码:H.264(MP4)保证兼容性,H.265实现更小体积
  2. FFmpeg 命令示例
bash
undefined

Compress video for web (H.264, CRF 23 = good quality)

Compress video for web (H.264, CRF 23 = good quality)

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a aac -b:a 128k output.mp4
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a aac -b:a 128k output.mp4

Create WebM version (smaller, modern browsers)

Create WebM version (smaller, modern browsers)

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus output.webm

Extract poster image

Extract poster image

ffmpeg -i input.mp4 -ss 00:00:01 -vframes 1 poster.jpg
ffmpeg -i input.mp4 -ss 00:00:01 -vframes 1 poster.jpg

Resize to 720p

Resize to 720p

ffmpeg -i input.mp4 -vf scale=1280:720 -c:v libx264 -crf 23 output-720p.mp4

3. **HTML with fallbacks**

```html
<video autoplay muted loop playsinline poster="poster.jpg">
    <source src="video.webm" type="video/webm">
    <source src="video.mp4" type="video/mp4">
</video>
ffmpeg -i input.mp4 -vf scale=1280:720 -c:v libx264 -crf 23 output-720p.mp4

3. **带降级兼容的HTML代码**

```html
<video autoplay muted loop playsinline poster="poster.jpg">
    <source src="video.webm" type="video/webm">
    <source src="video.mp4" type="video/mp4">
</video>

External Video Hosting

第三方视频托管

For longer videos, use:
  • YouTube - Free, good performance, ads
  • Vimeo - Ad-free, professional
  • Bunny Stream - Cheap, fast CDN
  • Cloudflare Stream - Good for high traffic
对于长视频,推荐使用:
  • YouTube - 免费、性能良好,但含广告
  • Vimeo - 无广告、专业级
  • Bunny Stream - 低成本、CDN加速
  • Cloudflare Stream - 适合高流量场景

Lazy Load Videos

视频懒加载

javascript
// Lazy load video on scroll
const videoObserver = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            const video = entry.target;
            video.src = video.dataset.src;
            video.load();
            videoObserver.unobserve(video);
        }
    });
});

document.querySelectorAll('video[data-src]').forEach(video => {
    videoObserver.observe(video);
});

javascript
// Lazy load video on scroll
const videoObserver = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            const video = entry.target;
            video.src = video.dataset.src;
            video.load();
            videoObserver.unobserve(video);
        }
    });
});

document.querySelectorAll('video[data-src]').forEach(video => {
    videoObserver.observe(video);
});

Caching

缓存配置

LiteSpeed Cache Configuration

LiteSpeed Cache 配置

php
// wp-config.php settings
define('LITESPEED_ON', true);
define('LITESPEED_CACHE_DIR', WP_CONTENT_DIR . '/cache/litespeed/');
Recommended LiteSpeed Settings:
SettingValue
Enable CacheOn
Cache Logged-in UsersOff (unless needed)
Cache MobileOn
TTL604800 (7 days)
Browser CacheOn
Browser Cache TTL31557600 (1 year)
Minify CSSOn
Minify JSOn
Combine CSSTest carefully
Combine JSTest carefully
HTTP/2 PushCSS, JS
Lazy Load ImagesOn
WebP ReplacementOn (if EWWW handles it, disable here)
php
// wp-config.php settings
define('LITESPEED_ON', true);
define('LITESPEED_CACHE_DIR', WP_CONTENT_DIR . '/cache/litespeed/');
推荐的LiteSpeed 设置:
设置项取值
启用缓存开启
缓存已登录用户关闭(除非有需求)
缓存移动端开启
TTL604800(7天)
浏览器缓存开启
浏览器缓存TTL31557600(1年)
压缩CSS开启
压缩JS开启
合并CSS谨慎测试后启用
合并JS谨慎测试后启用
HTTP/2 推送CSS、JS
图片懒加载开启
WebP 替换开启(若EWWW已处理则关闭)

Object Cache (Redis)

对象缓存(Redis)

php
// wp-config.php
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_DATABASE', 0);
define('WP_CACHE', true);

// Install Redis Object Cache plugin
php
// wp-config.php
define('WP_REDIS_HOST', '127.0.0.1');
define('WP_REDIS_PORT', 6379);
define('WP_REDIS_DATABASE', 0);
define('WP_CACHE', true);

// Install Redis Object Cache plugin

Transient Caching

临时缓存(Transient)

php
// Cache expensive queries
function get_featured_properties() {
    $cache_key = 'featured_properties';
    $properties = get_transient($cache_key);

    if (false === $properties) {
        $properties = new WP_Query([
            'post_type' => 'property',
            'posts_per_page' => 6,
            'meta_key' => '_featured',
            'meta_value' => '1'
        ]);

        set_transient($cache_key, $properties, HOUR_IN_SECONDS);
    }

    return $properties;
}

// Clear cache on update
function clear_property_cache($post_id) {
    if ('property' === get_post_type($post_id)) {
        delete_transient('featured_properties');
    }
}
add_action('save_post', 'clear_property_cache');

php
// Cache expensive queries
function get_featured_properties() {
    $cache_key = 'featured_properties';
    $properties = get_transient($cache_key);

    if (false === $properties) {
        $properties = new WP_Query([
            'post_type' => 'property',
            'posts_per_page' => 6,
            'meta_key' => '_featured',
            'meta_value' => '1'
        ]);

        set_transient($cache_key, $properties, HOUR_IN_SECONDS);
    }

    return $properties;
}

// Clear cache on update
function clear_property_cache($post_id) {
    if ('property' === get_post_type($post_id)) {
        delete_transient('featured_properties');
    }
}
add_action('save_post', 'clear_property_cache');

Asset Optimization

资源优化

CSS Optimization

CSS 优化

php
// Remove unused block styles
function theme_remove_block_styles() {
    wp_dequeue_style('wp-block-library');
    wp_dequeue_style('wp-block-library-theme');
    wp_dequeue_style('global-styles');
}
add_action('wp_enqueue_scripts', 'theme_remove_block_styles', 100);

// Defer non-critical CSS
function theme_defer_styles($html, $handle, $href, $media) {
    $defer_handles = ['theme-animations', 'font-awesome'];

    if (in_array($handle, $defer_handles)) {
        return '<link rel="preload" as="style" href="' . $href . '" onload="this.onload=null;this.rel=\'stylesheet\'">' .
               '<noscript><link rel="stylesheet" href="' . $href . '"></noscript>';
    }

    return $html;
}
add_filter('style_loader_tag', 'theme_defer_styles', 10, 4);
php
// Remove unused block styles
function theme_remove_block_styles() {
    wp_dequeue_style('wp-block-library');
    wp_dequeue_style('wp-block-library-theme');
    wp_dequeue_style('global-styles');
}
add_action('wp_enqueue_scripts', 'theme_remove_block_styles', 100);

// Defer non-critical CSS
function theme_defer_styles($html, $handle, $href, $media) {
    $defer_handles = ['theme-animations', 'font-awesome'];

    if (in_array($handle, $defer_handles)) {
        return '<link rel="preload" as="style" href="' . $href . '" onload="this.onload=null;this.rel=\'stylesheet\'">' .
               '<noscript><link rel="stylesheet" href="' . $href . '"></noscript>';
    }

    return $html;
}
add_filter('style_loader_tag', 'theme_defer_styles', 10, 4);

JavaScript Optimization

JavaScript 优化

php
// Defer scripts
function theme_defer_scripts($tag, $handle, $src) {
    $defer_scripts = ['theme-main', 'gsap', 'gsap-scrolltrigger'];

    if (in_array($handle, $defer_scripts)) {
        return str_replace(' src', ' defer src', $tag);
    }

    return $tag;
}
add_filter('script_loader_tag', 'theme_defer_scripts', 10, 3);

// Remove jQuery if not needed
function theme_remove_jquery() {
    if (!is_admin()) {
        wp_deregister_script('jquery');
        wp_deregister_script('jquery-migrate');
    }
}
add_action('wp_enqueue_scripts', 'theme_remove_jquery');
php
// Defer scripts
function theme_defer_scripts($tag, $handle, $src) {
    $defer_scripts = ['theme-main', 'gsap', 'gsap-scrolltrigger'];

    if (in_array($handle, $defer_scripts)) {
        return str_replace(' src', ' defer src', $tag);
    }

    return $tag;
}
add_filter('script_loader_tag', 'theme_defer_scripts', 10, 3);

// Remove jQuery if not needed
function theme_remove_jquery() {
    if (!is_admin()) {
        wp_deregister_script('jquery');
        wp_deregister_script('jquery-migrate');
    }
}
add_action('wp_enqueue_scripts', 'theme_remove_jquery');

Font Optimization

字体优化

php
// Preload fonts
function theme_preload_fonts() {
    $fonts = [
        '/assets/fonts/inter-var.woff2',
        '/assets/fonts/playfair-display.woff2'
    ];

    foreach ($fonts as $font) {
        echo '<link rel="preload" href="' . get_theme_file_uri($font) . '" as="font" type="font/woff2" crossorigin>';
    }
}
add_action('wp_head', 'theme_preload_fonts', 1);
css
/* Use font-display: swap */
@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-var.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

php
// Preload fonts
function theme_preload_fonts() {
    $fonts = [
        '/assets/fonts/inter-var.woff2',
        '/assets/fonts/playfair-display.woff2'
    ];

    foreach ($fonts as $font) {
        echo '<link rel="preload" href="' . get_theme_file_uri($font) . '" as="font" type="font/woff2" crossorigin>';
    }
}
add_action('wp_head', 'theme_preload_fonts', 1);
css
/* Use font-display: swap */
@font-face {
    font-family: 'Inter';
    src: url('fonts/inter-var.woff2') format('woff2');
    font-weight: 100 900;
    font-display: swap;
}

Database Optimization

数据库优化

Regular Maintenance

定期维护SQL命令

sql
-- Delete old revisions (keep last 5)
DELETE FROM wp_posts WHERE post_type = 'revision'
AND ID NOT IN (
    SELECT * FROM (
        SELECT ID FROM wp_posts WHERE post_type = 'revision'
        ORDER BY post_date DESC LIMIT 5
    ) AS t
);

-- Delete expired transients
DELETE FROM wp_options WHERE option_name LIKE '%_transient_%'
AND option_value < UNIX_TIMESTAMP();

-- Delete orphaned postmeta
DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;

-- Optimize tables
OPTIMIZE TABLE wp_posts, wp_postmeta, wp_options, wp_comments, wp_commentmeta;
sql
-- Delete old revisions (keep last 5)
DELETE FROM wp_posts WHERE post_type = 'revision'
AND ID NOT IN (
    SELECT * FROM (
        SELECT ID FROM wp_posts WHERE post_type = 'revision'
        ORDER BY post_date DESC LIMIT 5
    ) AS t
);

-- Delete expired transients
DELETE FROM wp_options WHERE option_name LIKE '%_transient_%'
AND option_value < UNIX_TIMESTAMP();

-- Delete orphaned postmeta
DELETE pm FROM wp_postmeta pm
LEFT JOIN wp_posts p ON pm.post_id = p.ID
WHERE p.ID IS NULL;

-- Optimize tables
OPTIMIZE TABLE wp_posts, wp_postmeta, wp_options, wp_comments, wp_commentmeta;

WP-CLI Commands

WP-CLI 命令

bash
undefined
bash
undefined

Delete revisions

Delete revisions

wp post delete $(wp post list --post_type=revision --format=ids)
wp post delete $(wp post list --post_type=revision --format=ids)

Delete transients

Delete transients

wp transient delete --expired
wp transient delete --expired

Optimize database

Optimize database

wp db optimize
wp db optimize

Search-replace for migrations

Search-replace for migrations

wp search-replace 'old-domain.com' 'new-domain.com' --dry-run
undefined
wp search-replace 'old-domain.com' 'new-domain.com' --dry-run
undefined

Limit Revisions

限制文章修订版本数

php
// wp-config.php
define('WP_POST_REVISIONS', 5);
// Or disable completely
define('WP_POST_REVISIONS', false);

php
// wp-config.php
define('WP_POST_REVISIONS', 5);
// Or disable completely
define('WP_POST_REVISIONS', false);

CDN Configuration

CDN 配置

Cloudflare Settings

Cloudflare 设置

SettingValue
SSL/TLSFull (Strict)
Always Use HTTPSOn
Auto MinifyCSS, JS (test first)
BrotliOn
Browser Cache TTL4 hours to 1 year
Rocket LoaderOff (conflicts with GSAP)
MirageOn (mobile image optimization)
PolishLossy (image optimization)
WebPOn
设置项取值
SSL/TLS完全(严格)
始终使用HTTPS开启
自动压缩CSS、JS(先测试)
Brotli压缩开启
浏览器缓存TTL4小时至1年
Rocket Loader关闭(与GSAP冲突)
Mirage开启(移动端图片优化)
Polish有损压缩(图片优化)
WebP开启

Origin Headers

源站响应头配置

apache
undefined
apache
undefined

.htaccess - Cache headers

.htaccess - Cache headers

<IfModule mod_expires.c> ExpiresActive On ExpiresByType image/webp "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType font/woff2 "access plus 1 year" </IfModule>
<IfModule mod_expires.c> ExpiresActive On ExpiresByType image/webp "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/svg+xml "access plus 1 year" ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType font/woff2 "access plus 1 year" </IfModule>

Enable Gzip/Brotli

Enable Gzip/Brotli

<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/css AddOutputFilterByType DEFLATE application/javascript application/json AddOutputFilterByType DEFLATE image/svg+xml </IfModule> ```
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/css AddOutputFilterByType DEFLATE application/javascript application/json AddOutputFilterByType DEFLATE image/svg+xml </IfModule> ```

Speed Testing

速度测试

Tools

测试工具

  1. PageSpeed Insights - https://pagespeed.web.dev
  2. GTmetrix - https://gtmetrix.com
  3. WebPageTest - https://webpagetest.org
  4. Chrome DevTools - Lighthouse audit
  1. PageSpeed Insights - https://pagespeed.web.dev
  2. GTmetrix - https://gtmetrix.com
  3. WebPageTest - https://webpagetest.org
  4. Chrome DevTools - Lighthouse 审计

Command Line Testing

命令行测试

bash
undefined
bash
undefined

Using Lighthouse CLI

Using Lighthouse CLI

npm install -g lighthouse lighthouse https://example.com --output=html --output-path=./report.html
npm install -g lighthouse lighthouse https://example.com --output=html --output-path=./report.html

Using WebPageTest API

Using WebPageTest API

Automated Speed Monitoring

自动化速度监控

python
#!/usr/bin/env python3
"""
Speed test automation using PageSpeed Insights API
"""
import requests
import json

def test_pagespeed(url, api_key=None):
    endpoint = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed'
    params = {
        'url': url,
        'strategy': 'mobile',
        'category': ['performance', 'accessibility', 'best-practices', 'seo']
    }
    if api_key:
        params['key'] = api_key

    response = requests.get(endpoint, params=params)
    data = response.json()

    lighthouse = data['lighthouseResult']
    categories = lighthouse['categories']

    return {
        'performance': int(categories['performance']['score'] * 100),
        'accessibility': int(categories['accessibility']['score'] * 100),
        'best_practices': int(categories['best-practices']['score'] * 100),
        'seo': int(categories['seo']['score'] * 100),
        'lcp': lighthouse['audits']['largest-contentful-paint']['displayValue'],
        'cls': lighthouse['audits']['cumulative-layout-shift']['displayValue'],
        'fcp': lighthouse['audits']['first-contentful-paint']['displayValue']
    }

if __name__ == '__main__':
    result = test_pagespeed('https://example.com')
    print(json.dumps(result, indent=2))

python
#!/usr/bin/env python3
"""
Speed test automation using PageSpeed Insights API
"""
import requests
import json

def test_pagespeed(url, api_key=None):
    endpoint = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed'
    params = {
        'url': url,
        'strategy': 'mobile',
        'category': ['performance', 'accessibility', 'best-practices', 'seo']
    }
    if api_key:
        params['key'] = api_key

    response = requests.get(endpoint, params=params)
    data = response.json()

    lighthouse = data['lighthouseResult']
    categories = lighthouse['categories']

    return {
        'performance': int(categories['performance']['score'] * 100),
        'accessibility': int(categories['accessibility']['score'] * 100),
        'best_practices': int(categories['best-practices']['score'] * 100),
        'seo': int(categories['seo']['score'] * 100),
        'lcp': lighthouse['audits']['largest-contentful-paint']['displayValue'],
        'cls': lighthouse['audits']['cumulative-layout-shift']['displayValue'],
        'fcp': lighthouse['audits']['first-contentful-paint']['displayValue']
    }

if __name__ == '__main__':
    result = test_pagespeed('https://example.com')
    print(json.dumps(result, indent=2))

Performance Checklist

性能优化检查清单

Images

图片

  • All images compressed
  • WebP format with fallbacks
  • Lazy loading enabled
  • Responsive images (srcset)
  • LCP image preloaded
  • No images larger than needed
  • 所有图片已压缩
  • 使用WebP格式并提供降级兼容
  • 启用懒加载
  • 配置响应式图片(srcset)
  • 预加载LCP图片
  • 无过大尺寸的图片

Videos

视频

  • Compressed before upload
  • Poster images set
  • Lazy loaded if below fold
  • Consider external hosting for long videos
  • 上传前已压缩
  • 设置封面图
  • 首屏外的视频启用懒加载
  • 长视频考虑使用第三方托管

Caching

缓存

  • Page caching enabled
  • Browser caching configured
  • Object cache (Redis) if high traffic
  • CDN configured
  • 页面缓存已启用
  • 浏览器缓存已配置
  • 高流量场景启用对象缓存(Redis)
  • CDN已配置

Assets

资源

  • CSS/JS minified
  • Critical CSS inlined (optional)
  • Unused CSS removed
  • Scripts deferred
  • Fonts preloaded with font-display: swap
  • CSS/JS已压缩
  • 关键CSS内联(可选)
  • 移除未使用的CSS
  • 脚本已延迟加载
  • 字体预加载并设置font-display: swap

Database

数据库

  • Revisions limited
  • Expired transients cleaned
  • Orphaned meta cleaned
  • Autoload options reviewed
  • 限制文章修订版本数
  • 清理过期的临时缓存
  • 清理孤立的元数据
  • 检查自动加载选项

Third Party

第三方服务

  • Minimal plugins
  • No render-blocking third-party scripts
  • Analytics async/deferred
  • Social embeds lazy loaded

  • 插件数量精简
  • 无阻塞渲染的第三方脚本
  • 分析脚本异步/延迟加载
  • 社交嵌入内容懒加载

Quick Wins

快速优化技巧

  1. Enable caching - Biggest impact
  2. Compress images - Second biggest
  3. Use CDN - Global performance
  4. Defer JS - Improve LCP/FCP
  5. Preload fonts - Reduce CLS
  6. Remove unused plugins - Less bloat

  1. 启用缓存 - 影响最大的优化项
  2. 压缩图片 - 第二大影响项
  3. 使用CDN - 提升全球访问性能
  4. 延迟加载JS - 改善LCP/FCP指标
  5. 预加载字体 - 减少CLS指标
  6. 移除未使用的插件 - 减少网站冗余

Resources

参考资源