توضیحات
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 preconnect 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 embed’s 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 aren’t 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 preconnect 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 preconnect link for https://i.ytimg.com
which is the domain from which YouTube video poster images are served. Such preconnect 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, you’ll 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 of a Classic Block.
There are currently no settings and no user interface for this plugin since it is designed to work without any configuration.
نصب
Installation from within WordPress
- Visit Plugins > Add New.
- Search for Embed Optimizer.
- Install and activate the Embed Optimizer plugin.
Manual installation
- Upload the entire
embed-optimizer
folder to the/wp-content/plugins/
directory. - Visit Plugins.
- Activate the Embed Optimizer plugin.
سوالات متداول
-
Where can I submit my plugin feedback?
-
Feedback is encouraged and much appreciated, especially since this plugin may contain future WordPress core features. If you have suggestions or requests for new features, you can submit them as an issue in the WordPress Performance Team’s GitHub repository. If you need help with troubleshooting or have a question about the plugin, please create a new topic on our support forum.
-
Where can I report security bugs?
-
The Performance team and WordPress community take security bugs seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.
To report a security issue, please visit the WordPress HackerOne program.
-
How can I contribute to the plugin?
-
Contributions are always welcome! Learn more about how to get involved in the Core Performance Team Handbook.
The plugin source code is located in the WordPress/performance repo on GitHub.
نقد و بررسیها
نقد و بررسیای برای این افزونه یافت نشد.
توسعه دهندگان و همکاران
“Embed Optimizer” نرم افزار متن باز است. افراد زیر در این افزونه مشارکت کردهاند.
مشارکت کنندگان“Embed Optimizer” به 5 زبان ترجمه شده است. با تشکر از مترجمین برای همکاری و کمکهایشان.
ترجمه “Embed Optimizer” به زبان شما.
علاقه مند به توسعه هستید؟
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
گزارش تغییرات
0.3.0
Enhancements
- 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
Enhancements
- Facilitate embedding of Embed Optimizer. (1337)
- Leverage Optimization Detective to optimize embeds in Embed Optimizer. (1302)
0.1.2
Enhancements
- Improve overall code quality with stricter static analysis checks. (775)
- Bump minimum PHP requirement to 7.2. (1130)
Bug Fixes
- Hide post embed iframes with visibility:hidden instead of clipping. (1192)
0.1.1
0.1.0
- Initial release.