[WordPress] 外掛分享: WP HeadJS

前言介紹

  • 這款 WordPress 外掛「WP HeadJS」是 2012-06-16 上架。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2012-06-17,距離現在已有 4704 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 2.9.1 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

beezeee |

外掛標籤

headjs | javascript | wp_enqueue_script |

內容簡介

這個外掛使用 wp_print_scripts 行動鉤子,而不是替代實現所使用的輸出緩衝和 regex。

這種方法的缺點是,只有通過 wp_enqueue_script 載入的腳本會受到該插件的影響,好處是避免在每個頁面加載時使用輸出緩衝以提高性能。

該插件將保留通過 wp_localize_script 添加的任何本地化,並使用傳遞給 wp_enqueue_script 的第一個參數作為 head.js 調用中腳本的標籤。例如,

wp_enqueue_script('jquery','https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');

會顯示為

head.js({"jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"});

這使您能夠在特定腳本準備就緒時運行回調,例如

head.ready('jquery',function(){
//當 jquery 加載時執行某些操作
});

有關 HeadJS 用法的更多信息,請參見 http://headjs.com/

原文外掛簡介

This plugin uses the wp_print_scripts action hook, as opposed to output buffering and regex used by alternative implementations.
The downside of this method is that only scripts loaded via wp_enqueue_script will be affected by the plugin, the upside is better
performance by avoiding output buffering on every page load.
The plugin will preserve any localizations added via wp_localize_script, and uses the first parameter passed to wp_enqueue_script
as the label for the script in the head.js call. For example,
wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');

would show up as
head.js({"jquery": "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"});

This allows you to run callbacks when specific scripts are ready, such as
head.ready('jquery', function() {
//do something when jquery is loaded
});

For more on HeadJS usage, see http://headjs.com/

各版本下載點

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

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


最新版本

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

  • Smart JavaScript Auto Loader 》智慧 JavaScript 自動加載程式外掛(前身為 JavaScript AutoLoader)允許您載入其他 JavaScript 檔案,而無需更改佈景主題目錄中的檔案, 使用方法, 只需將其...。
  • Debug Bar List Script & Style Dependencies 》我們都知道在 WordPress 中添加 script 或 style 時,我們應該使用 wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ) 和 wp_enqueue_style( $ha...。
  • Scripts 》啟用此外掛可讓您定義希望在前端使用哪些 WordPress 內建的 Javascript 檔案,同時也可下載並提供多種前端開發函式庫來自他們在 Github 儲存庫的位置。, 文件...。
  • Post Head Includes 》這個外掛能夠輕鬆地在每篇文章中加入腳本和樣式表。這是開發人員為其客戶創建自定義頁面的優秀工具,同時也適用於博主將內聯 CSS 和 JS 與其文章內容分離的需...。

文章
Filter
Apply Filters
Mastodon