
內容簡介
這個外掛可以將任何外掛或佈景主題的資源來源替換為您自己所需的來源。主要目的是幫助 WordPress 使用者更改某些外掛使用的緩慢第三方腳本或樣式,進而優化該些國家的網站載入速度。
通常,您需要使用一些編程技巧來查找目標外掛的原始 enqueue 方法,然後將其dequeue,再enqueue您自己的資源檔案版本。但是,您需要小心,並遵循原始外掛enqueue原方式,以及依據相同的依賴關係以及版本號碼。否則,您可能會遇到一些意外問題。
有了這個外掛的幫助,您可以輕鬆地替換資源檔案,而不需要任何編程技巧。
此外掛不是用來自動本機托管第三方資源檔案,但您也可以這樣使用。請上傳您自己的本地檔案版本到更好和安全的文件夾中(可能是您的佈景主題文件夾),獲取公共可訪問的URL,在外掛的設定頁面使用它。試試看並玩得開心。
工作原理
一旦設定新的替換,此外掛將檢查所有排隊的腳本和樣式資源URL。如果找到符合的URL,它將使用您的替換URL替換目標URL。
此外掛不會dequeue目標資源,也不會enqueue您的替換資源。如果新的enqueue不遵循原始外掛或佈景主題,例如缺少依賴項或版本號不正確等,可能會發生問題。
如果目標資源URL不是開發人員使用標準的 WordPress enqueue script方法,替換將無法運作。
使用案例
從2021年9月底開始,馬來西亞發生阻擋,不允許所有當地ISP網路訪問maxcdn.bootstrapcdn.com。
如果您網站上有個外掛使用在maxcdn.bootstrapcdn.com上托管的資源檔案,馬來西亞的訪客會遇到超級緩慢的載入問題。
有了這個外掛的幫助,您可以輕鬆地將此資源檔案的URL替換為Cdnjs.cloudflare.com,而不會干擾原始外掛的功能。
此使用案例的教程如下:
解決馬來西亞的 maxcdn bootstrapcdn 問題
外掛標籤
開發者團隊
原文外掛簡介
Replace any plugin or theme asset source with your own desired source. Main purpose is to help WordPress users to change the slow third party scripts or styles which using by some plugins but slow load speed in certain countries.
Usually, you could use some coding skills to find the original enqueue method from the target plugin, then dequeue it, and enqueue your own version of asset file. But you need to take care and follow the same way how the original plugin enqueued and the dependency plus version. Otherwise, you might encounter some unexpected issues.
With the help of this plugin, you can easily replace the asset source file without coding skills.
This plugin is not meant to auto local host the third party asset file, but you could use for it too. Upload your own local version of asset file in a better and secured folder (maybe from your theme folder), get the public accessible url, use it on the plugin setting page. Just try it out and have fun.
How It Works
Once a new replacement set, this plugin will do a match on all queued asset styles and scripts source. If found the matching source, it will replaces target source URL with your replacement URL.
This plugin is not going to dequeue the target asset and enqueue your replacement asset. Issue might be happened if the new enqueue not follow the original plugin or theme like missing dependency or version incorrect etc.
If the target asset url not using the standard WordPress enqueue script method by the developer, the replacement will not works.
Use Case
There is a block in Malaysia since end of September 2021, which not allowed all local ISP network to access maxcdn.bootstrapcdn.com.
If there is a plugin in your site using the asset file hosted on maxcdn.bootstrapcdn.com, the visitor from Malaysia will encounter super slow loading issue.
With the help of this plugin, you can easily replace this asset file url to maybe cdnjs.cloudflare.com without disturbing the functionality of the original plugin.
Tutorial for this use case:
Solve maxcdn bootstrapcdn problem in Malaysia
