Title: Embed Optimizer
Author: WordPress Performance Team
Published: <strong>20 ខែ​មីនា, 2024</strong>
Last modified: 27 ខែ​កុម្ភៈ, 2026

---

ស្វែងរក កម្មវិធីបន្ថែម

![](https://ps.w.org/embed-optimizer/assets/banner-772x250.png?rev=3098223)

![](https://ps.w.org/embed-optimizer/assets/icon.svg?rev=3098223)

# Embed Optimizer

 By [WordPress Performance Team](https://profiles.wordpress.org/performanceteam/)

[Download](https://downloads.wordpress.org/plugin/embed-optimizer.1.0.0-beta5.zip)

 * [Details](https://km.wordpress.org/plugins/embed-optimizer/#description)
 * [Reviews](https://km.wordpress.org/plugins/embed-optimizer/#reviews)
 *  [Installation](https://km.wordpress.org/plugins/embed-optimizer/#installation)
 * [Development](https://km.wordpress.org/plugins/embed-optimizer/#developers)

 [Support](https://wordpress.org/support/plugin/embed-optimizer/)

## Description

This plugin’s purpose is to optimize the performance of [embeds in WordPress](https://wordpress.org/documentation/article/embeds/),
such as Tweets, YouTube videos, TikToks, and others.

The current optimizations include:

 1. Lazy loading embeds just before they come into view.
 2. Adding dns-prefetch links for embeds in the initial viewport.
 3. 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](https://wordpress.org/plugins/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](https://make.wordpress.org/core/2021/07/15/refining-wordpress-cores-lazy-loading-implementation/)
[lazy loading](https://make.wordpress.org/core/2021/07/15/refining-wordpress-cores-lazy-loading-implementation/)`
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](https://wordpress.org/plugins/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, 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 
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.

## Installation

#### Installation from within WordPress

 1. Visit **Plugins > Add New**.
 2. Search for **Embed Optimizer**.
 3. Install and activate the **Embed Optimizer** plugin.

#### Manual installation

 1. Upload the entire `embed-optimizer` folder to the `/wp-content/plugins/` directory.
 2. Visit **Plugins**.
 3. Activate the **Embed Optimizer** plugin.

## FAQ

### 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](https://github.com/WordPress/performance/issues/new/choose).
If you need help with troubleshooting or have a question about the plugin, please
[create a new topic on our support forum](https://wordpress.org/support/plugin/embed-optimizer/#new-topic-0).

### 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](https://hackerone.com/wordpress)
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](https://make.wordpress.org/performance/handbook/get-involved/).

The [plugin source code](https://github.com/WordPress/performance/tree/trunk/plugins/embed-optimizer)
is located in the [WordPress/performance](https://github.com/WordPress/performance)
repo on GitHub.

## Reviews

![](https://secure.gravatar.com/avatar/f6283355947a09bd508c2a126a4250d6ed75ebf9e4a9181e98aa006e1080c94f?
s=60&d=retro&r=g)

### 󠀁[Works great](https://wordpress.org/support/topic/works-great-9653/)󠁿

 [Liups233](https://profiles.wordpress.org/liups12138/) 30 ខែ​កក្កដា, 2025

My theme is Mynote. This plugin works great

![](https://secure.gravatar.com/avatar/a8e5ea7f0444b2713592b315c4ffc22777d8887d3f37a8be28eb69123cba16bf?
s=60&d=retro&r=g)

### 󠀁[Doesn’t optimize, breaks embeds](https://wordpress.org/support/topic/doesnt-optimize-breaks-embeds/)󠁿

 [Mr Bachelor emgi](https://profiles.wordpress.org/emgi2/) 2 ខែ​កក្កដា, 2025 4 replies

Do not use it, I have been trying to figure out for days why my embeds on social
media apps dont show up with images. This plugin breaks them.

 [ Read all 2 reviews ](https://wordpress.org/support/plugin/embed-optimizer/reviews/)

## Contributors & Developers

“Embed Optimizer” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ WordPress Performance Team ](https://profiles.wordpress.org/performanceteam/)
 *   [ WordPress.org ](https://profiles.wordpress.org/wordpressdotorg/)

“Embed Optimizer” has been translated into 9 locales. Thank you to [the translators](https://translate.wordpress.org/projects/wp-plugins/embed-optimizer/contributors)
for their contributions.

[Translate “Embed Optimizer” into your language.](https://translate.wordpress.org/projects/wp-plugins/embed-optimizer)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/embed-optimizer/), 
check out the [SVN repository](https://plugins.svn.wordpress.org/embed-optimizer/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/embed-optimizer/)
by [RSS](https://plugins.trac.wordpress.org/log/embed-optimizer/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.0.0-beta5

**Bug Fixes**

 * Switch initial viewport embeds from preconnect to dns-prefetch links. ([2256](https://github.com/WordPress/performance/pull/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](https://github.com/nduc193) for [responsible disclosure](https://github.com/WordPress/performance/blob/trunk/SECURITY.md).(
   [2397](https://github.com/WordPress/performance/pull/2397))

#### 1.0.0-beta3

**Enhancements**

 * Add URL Metric mutation helpers to extension initialization API. ([1951](https://github.com/WordPress/performance/pull/1951))
 * Improve construction of inline scripts with `sourceURL`, hardened JSON encoding,
   and exporting JSON in separate script. ([2169](https://github.com/WordPress/performance/pull/2169))

#### 1.0.0-beta2

**Enhancements**

 * Update `OD_HTML_Tag_Processor::next_tag()` to allow `$query` arg and prepare 
   to skip visiting tag closers by default. ([1872](https://github.com/WordPress/performance/pull/1872))
 * Expose the logging functions to client-side extensions and automatically account
   for the value of `isDebug`. ([1895](https://github.com/WordPress/performance/pull/1895))

#### 1.0.0-beta1

**Enhancements**

 * Bump version to 1.0.0-beta1 to indicate graduation from being experimental. See
   [1846](https://github.com/WordPress/performance/pull/1846).
 * Use CSS range syntax in media queries. ([1833](https://github.com/WordPress/performance/pull/1833))

#### 0.4.1

**Bug Fixes**

 * Remove requirement for both mobile and desktop URL metrics to be collected for`
   preconnect` links to be added. ([1764](https://github.com/WordPress/performance/pull/1764))

#### 0.4.0

**Enhancements**

 * Incorporate media queries into preconnect links to account for whether embeds
   are in viewport. ([1654](https://github.com/WordPress/performance/pull/1654))
 * Serve unminified scripts when `SCRIPT_DEBUG` is enabled. ([1643](https://github.com/WordPress/performance/pull/1643))

#### 0.3.0

**Enhancements**

 * Leverage URL Metrics to reserve space for embeds to reduce CLS. ([1373](https://github.com/WordPress/performance/pull/1373))
 * Avoid lazy-loading images and embeds unless there are URL Metrics for both mobile
   and desktop. ([1604](https://github.com/WordPress/performance/pull/1604))

#### 0.2.0

**Enhancements**

 * Facilitate embedding of Embed Optimizer. ([1337](https://github.com/WordPress/performance/pull/1337))
 * Leverage Optimization Detective to optimize embeds in Embed Optimizer. ([1302](https://github.com/WordPress/performance/pull/1302))

#### 0.1.2

**Enhancements**

 * Improve overall code quality with stricter static analysis checks. ([775](https://github.com/WordPress/performance/issues/775))
 * Bump minimum PHP requirement to 7.2. ([1130](https://github.com/WordPress/performance/pull/1130))

**Bug Fixes**

 * Hide post embed iframes with visibility:hidden instead of clipping. ([1192](https://github.com/WordPress/performance/pull/1192))

#### 0.1.1

 * Use plugin slug for generator tag. ([1103](https://github.com/WordPress/performance/pull/1103))
 * Bump minimum required WP version to 6.4. ([1076](https://github.com/WordPress/performance/pull/1076))

#### 0.1.0

 * Initial release.

## Community plugin

This plugin is developed and supported by a community. [Contribute to this plugin](https://github.com/WordPress/performance)

## មេតា

 *  Version **1.0.0-beta5**
 *  Last updated **2 ខែ មុន**
 *  Active installations **50,000+**
 *  WordPress version ** 6.6 or higher **
 *  Tested up to **7.0**
 *  PHP version ** 7.2 or higher **
 *  Languages
 * [Chinese (Taiwan)](https://tw.wordpress.org/plugins/embed-optimizer/), [English (US)](https://wordpress.org/plugins/embed-optimizer/),
   [Persian](https://fa.wordpress.org/plugins/embed-optimizer/), [Portuguese (Brazil)](https://br.wordpress.org/plugins/embed-optimizer/),
   [Portuguese (Portugal)](https://pt.wordpress.org/plugins/embed-optimizer/), [Spanish (Chile)](https://cl.wordpress.org/plugins/embed-optimizer/),
   [Spanish (Spain)](https://es.wordpress.org/plugins/embed-optimizer/), [Swedish](https://sv.wordpress.org/plugins/embed-optimizer/),
   [Turkish](https://tr.wordpress.org/plugins/embed-optimizer/), and [Vietnamese](https://vi.wordpress.org/plugins/embed-optimizer/).
 *  [Translate into your language](https://translate.wordpress.org/projects/wp-plugins/embed-optimizer)
 * Tags
 * [Embeds](https://km.wordpress.org/plugins/tags/embeds/)[optimization-detective](https://km.wordpress.org/plugins/tags/optimization-detective/)
   [performance](https://km.wordpress.org/plugins/tags/performance/)
 *  [Advanced View](https://km.wordpress.org/plugins/embed-optimizer/advanced/)

## Ratings

 3 out of 5 stars.

 *  [  1 5-star review     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=2)
 *  [  1 1-star review     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/embed-optimizer/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/embed-optimizer/reviews/)

## Contributors

 *   [ WordPress Performance Team ](https://profiles.wordpress.org/performanceteam/)
 *   [ WordPress.org ](https://profiles.wordpress.org/wordpressdotorg/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/embed-optimizer/)