M t
This plugin’s purpose is to optimize the performance of embeds in WordPress, such as Tweets, YouTube videos, TikToks, and others.
The current optimizations include:
- Lazy loading embeds just before they come into view.
- Adding dns-prefetch links for embeds in the initial viewport.
- Reserving space for embeds that resize to reduce layout shifting.
Lazy loading embeds improves performance because embeds are generally very resource-intensive, so lazy loading them ensures that they don’t compete with resources when the page is loading. Lazy loading of IFRAME-based embeds is handled simply by adding the loading=lazy attribute. Lazy loading embeds that include SCRIPT tags is handled by using an Intersection Observer to watch for when the embeds FIGURE container is going to enter the viewport, and then it dynamically inserts the SCRIPT tag.
This plugin also recommends that you install and activate the Optimization Detective plugin, which unlocks several optimizations beyond just lazy loading. Without Optimization Detective, lazy loading can actually degrade performance when an embed is positioned in the initial viewport. This is because lazy loading such viewport-initial elements can degrade LCP since rendering is delayed by the logic to determine whether the element is visible. This is why WordPress Core tries its best to avoid lazy loading IMG tags which appear in the initial viewport, although the server-side heuristics arent perfect. This is where Optimization Detective comes in since it detects whether an embed appears in any breakpoint-specific viewports, like mobile, tablet, and desktop. (See also the Image Prioritizer plugin which extends Optimization Detective to ensure lazy loading is correctly applied based on whether an IMG is in the initial viewport.)
When Optimization Detective is active, it will start keeping track of which embeds appear in the initial viewport based on actual visits to your site. With this information in hand, Embed Optimizer will then avoid lazy loading embeds which appear in the initial viewport. Furthermore, for such above-the-fold embeds Embed Optimizer will also add dns-prefetch links for resources known to be used by those embeds. For example, if a YouTube embed appears in the initial viewport, Embed Optimizer with Optimization Detective will omit loading=lazy while also adding a dns-prefetch link for https://i.ytimg.com which is the domain from which YouTube video poster images are served. Such links cause the initial-viewport embeds to load even faster.
The other major feature in Embed Optimizer enabled by Optimization Detective is the reduction of layout shifts caused by embeds that resize when they load. This is seen commonly in WordPress post embeds or Tweet embeds. Embed Optimizer keeps track of the resized heights of these embeds. With these resized heights stored, Embed Optimizer sets the appropriate height on the container FIGURE element as the viewport-specific min-height so that when the embed loads it does not cause a layout shift.
Since Optimization Detective relies on page visits to learn how the page is laid out, youll need to wait until you have visits from a mobile and desktop device to start seeing optimizations applied. Also, note that Optimization Detective does not apply optimizations by default for logged-in admin users.
Please note that the optimizations are intended to apply to Embed blocks. So if you do not see optimizations applied, make sure that your embeds are not inside a Classic Block.
Your site must have the REST API accessible to unauthenticated frontend visitors since this is how metrics are collected about how a page should be optimized. There are currently no settings and no user interface for this plugin since it is designed to work without any configuration.
Ci t
Ci t t bn trong WordPress
- Hy truy cp Plugin > Thm mi.
- Tm kim Embed Optimizer.
- Ci t v kch hot plugin Embed Optimizer.
Ci t th cng
- Ti ln ton b th mc
embed-optimizervo th mc/wp-content/plugins/. - Truy cp Plugins.
- Kch hot plugin Embed Optimizer.
Hi p
-
Ti c th gi phn hi v plugin ca mnh u?
-
Phn hi c khuyn khch v nh gi cao, c bit l v plugin ny c th cha cc tnh nng ct li ca WordPress trong tng lai. Nu bn c xut hoc yu cu v cc tnh nng mi, bn c th gi chng di dng s c trong kho lu tr GitHub ca Nhm Hiu sut WordPress. Nu bn cn tr gip v khc phc s c hoc c cu hi v plugin, vui lng to mt ch mi trn din n h tr ca chng ti.
-
Ti c th bo co li bo mt u?
-
Nhm Hiu sut v cng ng WordPress rt coi trng cc li bo mt. Chng ti nh gi cao n lc ca bn trong vic tit l mt cch c trch nhim nhng pht hin ca mnh v s n lc ht sc ghi nhn nhng ng gp ca bn.
bo co s c bo mt, vui lng truy cp chng trnh WordPress HackerOne.
-
Lm cch no ti c th ng gp cho plugin?
-
Cc khon ng gp lun c cho n! Tm hiu thm v cch tham gia vo S tay nhm hiu sut ct li.
Cc m ngun plugin c t trong kho lu tr WordPress/performance trn GitHub.
nh gi
Ngi ng gp & Lp trnh vin
“Embed Optimizer” l m ngun m. Nhng ngi sau ng gp vo plugin ny.
Nhng ngi ng gp“Embed Optimizer” c dch qua 11 ngn ng. Cm n nhng ngi tham gia dch v ng gp ca h.
Dch “Embed Optimizer” sang ngn ng ca bn.
Mun tham gia pht trin?
Duyt code, check out SVN repository, hoc theo di nht k pht trin qua RSS.
Nht k thay i
1.0.0-beta5
Sa li
- Switch initial viewport embeds from preconnect to dns-prefetch links. (2256)
1.0.0-beta4
Security
- Add escaping for ID selector in styles added to reduce layout shifts. This fixes an XSS security vulnerability which required an authenticated user with at least a contributor role. Props to duc193 for responsible disclosure. (2397)
1.0.0-beta3
Ci tin
- Add URL Metric mutation helpers to extension initialization API. (1951)
- Improve construction of inline scripts with
sourceURL, hardened JSON encoding, and exporting JSON in separate script. (2169)
1.0.0-beta2
Ci tin
- Update
OD_HTML_Tag_Processor::next_tag()to allow$queryarg and prepare to skip visiting tag closers by default. (1872) - Expose the logging functions to client-side extensions and automatically account for the value of
isDebug. (1895)
1.0.0-beta1
Ci tin
- Bump version to 1.0.0-beta1 to indicate graduation from being experimental. See 1846.
- Use CSS range syntax in media queries. (1833)
0.4.1
Sa li
- Remove requirement for both mobile and desktop URL metrics to be collected for
preconnectlinks to be added. (1764)
0.4.0
Ci tin
- Incorporate media queries into preconnect links to account for whether embeds are in viewport. (1654)
- Serve unminified scripts when
SCRIPT_DEBUGis enabled. (1643)
0.3.0
Ci tin
- Leverage URL Metrics to reserve space for embeds to reduce CLS. (1373)
- Avoid lazy-loading images and embeds unless there are URL Metrics for both mobile and desktop. (1604)
0.2.0
Ci tin
- To iu kin nhng Embed Optimizer. (1337)
- Tn dng Optimization Detective ti u ha cc phn nhng trong Embed Optimizer. (1302)
0.1.2
Ci tin
- Ci thin cht lng m tng th vi cc kim tra phn tch tnh nghim ngt hn. (775)
- Nng yu cu PHP ti thiu ln 7.2. (1130)
Sa li
- n iframe nhng bi ng bng visibility:hidden thay v ct. (1192)
0.1.1
0.1.0
- Pht hnh ln u.