[WordPress] 外掛分享: PUZZLER is JS + CSS combine

首頁外掛目錄 › PUZZLER is JS + CSS combine
WordPress 外掛 PUZZLER is JS + CSS combine 的封面圖片
10+
安裝啟用
★★★★
4/5 分(4 則評價)
3738 天前
最後更新
問題解決
WordPress 3.4+ v1.0 上架:2015-12-22

內容簡介

Puzzler 是一個優秀的 JavaScript/CSS 聚合器,適合專業用戶使用:

自動將所有佇列中的腳本和樣式表合併成為單一檔案,以加快網站的載入速度。
無需設置即可立即啟動。
您可以將腳本和樣式表添加到佇列中、更改順序、進行編輯,Puzzler 會自動進行重新合併。

使用 Puzzler,讓你無憂無慮。

需要 PHP 5.4 或更高版本。

使用前需牢記 3 條關鍵規則:

第一個關鍵規則

所有腳本和樣式表必須僅在 1 個位置和 1 次中包含,例如在 wp_enqueue_scripts 鉤子中。

第二個關鍵規則

僅針對 media='all'(沒有選擇式的樣式表、標題或條件式)執行樣式表(css)聚合。

第三個關鍵規則

避免在條件式中註冊/佇列化腳本/樣式表。
add_action('wp_enqueue_scripts', 'my_enqueue_scripts');
function my_enqueue_scripts() {

// -- 錯誤的做法!
if ( is_single() || is_page() ) {
wp_enqueue_script('myscript');
}

// -- 正確的做法!
wp_enqueue_script('myscript');

}

特色

自動檢測檔案更改
聚合 CSS 後自動修正內部鏈接 (url/src)
在 Google PageSpeed Insights 上自動提高 20 分
聚合的腳本/樣式表可設置異步加載或延遲載入
與 Windows 兼容

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「PUZZLER is JS + CSS combine」→ 直接安裝(推薦)

原文外掛簡介

Puzzler – it excellent js/css aggregator for advanced users:

Automatically combines all enqueued scripts/styles into a single file, for faster loading blog.
Starts immediately without setting.
You can adds scripts and styles in queue, change the order, edit – and Puzzler automatically make recombines.

Puzzler – don’t worry be happy.
Require PHP 5.4 or high.
You should remember 3 key rules before using:
Key rule 1

All scripts and styles must include ONLY 1 time and ONLY in 1 place, e.g. in wp_enqueue_scripts hook

Key rule 2

Styles(css) aggregation perform only for media=’all’ ( without alternative stylesheets, titles, conditionals )

Key rule 3

Avoid register/enqueue scripts/styles in conditional expressions
add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’);
function my_enqueue_scripts() {

// -- don't do it !
if ( is_single() || is_page() ) {
wp_enqueue_script('myscript');
}

// -- correct !
wp_enqueue_script('myscript');

}

Features

Auto detect files change
Autocorrect internal links in the CSS after aggregation ( url/src )
Auto +20 scores in Google PageSpeed Insights
Async/lazy load aggregated scripts/styles
Windows compatible

延伸相關外掛

文章
Filter
Apply Filters
Mastodon