[WordPress] 外掛分享: Embed JavaScript File Content

首頁外掛目錄 › Embed JavaScript File Content
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
10+
安裝啟用
尚無評分
43 天前
最後更新
問題解決
WordPress 4.1+ PHP 5.4+ v1.0.2 上架:2020-04-28

內容簡介

此外掛已被退休且不再維護,主要用於將 JavaScript 文件內容嵌入到網頁中。由於 PHP 8 的變更,此外掛會導致致命錯誤,因此建議停用並移除。

【主要功能】
• 嵌入 JavaScript 代碼到 DOM
• 提供過濾器 embed_javascript_file_content_handles
• 支援將代碼直接放入 <script> 標籤

外掛標籤

開發者團隊

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

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Embed JavaScript File Content」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin is retired and no longer maintained. Please deactivate and remove it.
Version 1.0.2 exists only to carry this notice and to repair a fatal error: the
plugin called DOMDocument::loadHTML() statically, which PHP 8 rejects. Any site
that actually configured the filter has been showing “There has been a critical
error on this website” since its PHP 8 upgrade. Sites that installed the plugin
without configuring the filter were unaffected, because it does nothing until a
handle is passed to it.
What to do instead
If you wrote the script yourself, do not inline the file — write the code inline
in the first place. WordPress has supported that since 4.5:
wp_add_inline_script( 'my-handle', 'if (!("localStorage" in window)) { /* ... */ }', 'before' );

or, for code that has to run before anything else paints, print it in wp_head
directly. Both are simpler than routing a file through a plugin, and neither
breaks a Content Security Policy the way an inlined file does — this plugin sets
neither a nonce nor a hash, so a strict script-src blocks its output.
If you need the same for a script you do not control, our
Inline JavaScript in Head
plugin covers that case and is maintained. Note the difference: it moves the code
into the , while this plugin replaced the tag where it stood.
Why it is being retired
The benefit it was written for has largely gone. Under HTTP/2 and HTTP/3 requests
are multiplexed, so the per-file cost that made inlining worthwhile is mostly
gone, and inlining still costs you browser caching — the code travels with every
single HTML response. What remains is a narrow case: inlining a file you cannot
edit. That is not enough to keep a plugin for.
How it used to work
In some critical cases you cannot wait for a JavaScript file to load. Then you can benefit from better performance, if you embed the JavaScript code directly into the

文章
Filter
Mastodon