[WordPress] 外掛分享: Dependency Minification

前言介紹

  • 這款 WordPress 外掛「Dependency Minification」是 2013-08-06 上架。
  • 目前有 30 個安裝啟用數。
  • 上一次更新是 2015-02-25,距離現在已有 3721 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.5 以上版本才可以安裝。
  • 有 11 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

xwp | kucrut | lkraav | alex-ye | shadyvb | fjarrett | c3mdigital | westonruter |

外掛標籤

minify | compress | concatenate | performance | dependencies |

內容簡介

此外掛會自動將使用wp_enqueue_script 及 wp_enqueue_style 加入的所有腳本和樣式表合併和縮小為邏輯組。例如,頁面底部的腳本會被分組,同樣媒體(例如print)的樣式表會一起縮小。縮小是通過WP-Cron完成的,以避免競態條件並確保縮小過程不會減慢頁面響應速度。
這是Optimize Scripts插件的重新設計和重寫,現在取代了該插件。
特點:

縮小來源存儲在WP選項表中,因此不需要特殊的文件系統訪問。
縮小請求的端點為/_minified,可以進行配置。
管理頁面用於盤點縮小的腳本和樣式表,提供過期或清除緩存數據的方法。
必須排除縮小的依賴關係可能會通過dependency_minification_excluded過濾器排除。
預設情況下,托管在其他域上的相依關係會被排除,但可以通過過濾器dependency_minification_options過濾default_exclude_remote_dependencies選項,或通過前面提到的過濾器根據情況進行更改。
預設情況下,外部腳本不會被合併和縮小,但可以通過dependency_minification_excluded過濾器設定。
縮小源的緩存時間默認為1個月,但可以通過cache_control_max_age_cache選項進行配置。
如果縮小源尚不可用,頁面源將註明等待依賴關係縮小過程。
任何在縮小過程中發生的錯誤都會在前端以注釋的形式顯示,如果已啟用show_error_messages選項,則此類錯誤默認情況下已啟用WP_DEBUG。
如果縮小過程出錯,原始未縮小的來源將被提供並且該錯誤將被緩存1小時(默認情況下,通過cache_control_max_age_error進行配置),以防止連續的cron的回溯不斷地嘗試進行縮小。
緩存的縮小源使用Last-Modified和ETag響應標頭提供,請求將憑藉If-None-Match和If-Modified-Since來返回304 Not Modified的響應(可通過選項allow_not_modified_responses進行配置)。
附加到腳本的數據(例如通過wp_localize_script附加到腳本)也會一起合併並附加到新縮小的腳本上。
使用WP-Cron來啟動縮小過程,以避免競態條件,並確保頁面響應速度不會減慢。
過時的縮小腳本和樣式表一直保留到刷新,這可以確保引用過時縮小源的完整頁面緩存不會導致任何404。
可以使用gzip或deflate服務壓縮響應。
轉換樣式表中的相對路徑(例如背景圖像)為絕對路徑,以便它們不會404。

此插件的開發在GitHub上完成。歡迎提交拉取請求。在前往插件論壇之前,請參閱在此報告的問題。如果使用Nginx與此外掛一起運行,請閱讀附加文檔以了解更多資訊。

原文外掛簡介

This plugin takes all scripts and stylesheets that have been added via wp_enqueue_script and wp_enqueue_style
and automatically concatenates and minifies them into logical groups. For example, scripts in the footer get grouped
together and styles with the same media (e.g. print) get minified together. Minification is done via WP-Cron in order
to prevent race conditions and to ensure that the minification process does not slow down page responses.
This is a reincarnation and rewrite of the Optimize Scripts plugin,
which this plugin now supersedes.
Features:

Minified sources are stored in the WP Options table so no special filesystem access is required.
Endpoint for minified requests is at /_minified, which can be configured.
Admin page for taking inventory of minified scripts and stylesheets, with methods for expiring or purging the cached data.
Dependencies which must not be minified may be excluded via the dependency_minification_excluded filter.
Dependencies hosted on other domains are by default excluded, but this behavior can be changed by filtering the default_exclude_remote_dependencies option via the dependency_minification_options filter, or on a case-by-case basis via the filter previously mentioned.
By default excludes external scripts from being concatenated and minified, but they can be opted in via the dependency_minification_excluded filter.
The length of time that a minified source is cached defaults to 1 month, but can be configured via the cache_control_max_age_cache option.
If a minified source is not available yet, the page source will note that the dependency minification process is pending.
Any errors that occur during minification will be shown on the frontend in comments if the show_error_messages option is enabled; such errors are enabled by default if WP_DEBUG.
If the minification process errors out, the original unminified sources are served and the error is cached for 1 hour (by default, configured via cache_control_max_age_error) to prevent back-to-back crons from continually attempting to minify in perpetuity.
Cached minified sources are served with Last-Modified and ETag responses headers and requests will honor If-None-Match and If-Modified-Since to return 304 Not Modified responses (configurable via the allow_not_modified_responses option).
Data attached to scripts (e.g. via wp_localize_script) is also concatenated together and attached to the newly-minified script.
WP-Cron is utilized to initiate the minification process in order to prevent race conditions, and to ensure that page responses aren’t slowed down.
Stale minified scripts and stylesheets remain until replaced by refreshed ones; this ensures that full-page caches which reference stale minified sources won’t result in any 404s.
Can serve compressed responses with gzip or deflate.
Transforms relatives paths in stylesheets (e.g. background-images) to absolute ones, so that they don’t 404.

Development of this plugin is done on GitHub. Pull requests welcome. Please see issues reported there before going to the plugin forum.
If you are using Nginx with the default Varying Vagrant Vagrants config, you’ll want to remove css|js from this rule in nginx-wp-common.conf (or remove the rule altogether):
# Handle all static assets by serving the file directly. Add directives
# to send expires headers and turn off 404 error logging.
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 24h;
log_not_found off;
}

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Dependency Minification」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


最新版本

延伸相關外掛(你可能也想知道)

  • LiteSpeed Cache 》LiteSpeed Cache for WordPress(LSCWP)是一種全方位的網站加速外掛,包括獨家的伺服器層快取和一系列的優化功能。, LSCWP 支援 WordPress Multisite 及大多...。
  • Jetpack – WP Security, Backup, Speed, & Growth 》search engines, and grow your traffic with Jetpack. It’s the ultimate toolkit for WordPress professionals and beginners alike., , Customize and des...。
  • Image Optimizer – Optimize Images and Convert to WebP or AVIF 》外掛總結:, , - Image Optimizer 是一個易於使用的 WordPress 外掛,透過壓縮和調整大小的技術來減少圖像大小,同時保留最高的圖像品質。, - Image Optimize...。
  • WP Super Cache 》本外掛可以從您的動態 WordPress 部落格生成靜態 HTML 檔案。在產生 HTML 檔案後,您的網頁伺服器會傳送該檔案,而不是處理比較沉重、耗費更多資源的 WordPre...。
  • WP Fastest Cache 》han PNG or JPEG, which means faster downloads and less data consumption for your visitors, Database Cleanup – Detect and delete unnecessary d...。
  • ManageWP Worker 》, Want to clone or migrate your WordPress website to a new host or domain? No problem! With ManageWP, you can easily clone or migrate your website ...。
  • W3 Total Cache 》W3 Total Cache (W3TC) 透過整合內容傳遞網絡 (CDN) 和最新最佳實踐等功能,提高網站性能、減少加載時間,增進 SEO、核心 Web 主要指標和整體用戶體驗。W3TC ...。
  • Speed Optimizer – The All-In-One Performance-Boosting Plugin 》SiteGround Optimizer 插件是由 SiteGround 開發的,可以大幅提高任何托管環境下的 WordPress 網站性能。, 最初設計用於 SiteGround 的服務器,現在已經有近 ...。
  • Autoptimize 》Autoptimize 能夠輕鬆優化您的網站。它可以整合、縮小和快取腳本和樣式表,在默認情況下向頁面 head 中注入 CSS,但也可以內嵌關鍵 CSS 並延遲整合的完整 CSS...。
  • AMP 》「Page Experience」(PX)是一組排名訊號,包括「核心網頁素質」(Core Web Vitals,CWV),用來測量使用者與網頁互動的使用體驗。AMP 是一個強大的工具,能...。
  • WebP Express 》ch means less bandwidth usage and faster page load times., Easy to use - with little effort, WordPress site admins can have their site serving auto...。
  • Breeze – WordPress Cache Plugin 》Breeze是由Cloudways團隊開發的一款免費、簡單(卻功能強大)且使用者友好的WordPress快取外掛。它提供不同層級的WordPress效能優化選項,在WordPress、搭配W...。
  • Jetpack Boost – Website Speed, Performance and Critical CSS 》使用 Jetpack Boost 優化網頁性能加速你的 WordPress 網站。輕鬆啟用一鍵優化,提升核心 Web 重要指標。, 你是否知道,更快的網站可以:, , 在 Google 搜尋排...。
  • Custom Fonts – Host Your Fonts Locally 》此外掛能協助您輕鬆地在 WordPress 網站中嵌入自定義字型檔案 (woff2、woff、ttf、svg、eot、otf)。, 目前能與以下主題和外掛一起使用:, , Astra 主題, Beav...。
  • Redis Object Cache 》一個由 Redis 提供支援的持久化物件快取後端。支援 Predis、PhpRedis (PECL)、Relay、複寫、哨兵、叢集化和 WP-CLI。, 若要調整連線參數、前綴的快取鍵或設定...。

文章
Filter
Apply Filters
Mastodon