
內容簡介
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 兼容
外掛標籤
開發者團隊
原文外掛簡介
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
