Title: Embed Optimizer
Author: WordPress Performance Team
Published: <strong>20 mars 2024</strong>
Last modified: 27 februari 2026

---

Sök tillägg

![](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

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

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

 * [Detaljer](https://sv.wordpress.org/plugins/embed-optimizer/#description)
 * [Recensioner](https://sv.wordpress.org/plugins/embed-optimizer/#reviews)
 *  [Installation](https://sv.wordpress.org/plugins/embed-optimizer/#installation)
 * [Utveckling](https://sv.wordpress.org/plugins/embed-optimizer/#developers)

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

## Beskrivning

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 inifrån WordPress

 1. Besök **Tillägg > Lägg till nytt**.
 2. Sök efter **Embed Optimizer**.
 3. Installera och aktivera tillägget **Embed Optimizer**.

#### Manuell installation

 1. Ladda upp hela mappen `embed-optimizer` till katalogen `/wp-content/plugins/`.
 2. Besök **Tillägg**.
 3. Aktivera tillägget **Embed Optimizer**.

## Vanliga frågor

### Var kan jag skicka in min återkoppling om tillägget?

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).

### Var kan jag rapportera säkerhetsproblem?

Performance-teamet och WordPress-communityn tar säkerhetsfel på allvar. Vi uppskattar
dina ansträngningar att ansvarsfullt rapportera dina upptäckter och kommer att göra
allt vi kan för att erkänna dina bidrag.

För att rapportera ett säkerhetsproblem, besök [WordPress HackerOne](https://hackerone.com/wordpress)-
programmet.

### Hur kan jag bidra till tillägget?

Bidrag är alltid välkomna! Läs mer om hur du kan engagera dig i [Handboken för Core Performance-team](https://make.wordpress.org/performance/handbook/get-involved/).

Källkoden för [tillägget](https://github.com/WordPress/performance/tree/trunk/plugins/embed-optimizer)
finns i [WordPress/performance](https://github.com/WordPress/performance) filförvaret
på GitHub.

## Recensioner

![](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 juli 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 juli 2025 4 svar

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.

 [ Läs alla 2 betyg ](https://wordpress.org/support/plugin/embed-optimizer/reviews/)

## Bidragsgivare och utvecklare

”Embed Optimizer” är programvara med öppen källkod. Följande personer har bidragit
till detta tillägg.

Bidragande personer

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

”Embed Optimizer” har översatts till 9 språk. Tack till [översättarna](https://translate.wordpress.org/projects/wp-plugins/embed-optimizer/contributors)
för deras bidrag.

[Översätt ”Embed Optimizer” till ditt språk.](https://translate.wordpress.org/projects/wp-plugins/embed-optimizer)

### Intresserad av programutveckling?

[Läs programkoden](https://plugins.trac.wordpress.org/browser/embed-optimizer/),
kika på [SVN-filförvaret](https://plugins.svn.wordpress.org/embed-optimizer/) eller
prenumerera på [utvecklarloggen](https://plugins.trac.wordpress.org/log/embed-optimizer/)
via [RSS](https://plugins.trac.wordpress.org/log/embed-optimizer/?limit=100&mode=stop_on_copy&format=rss).

## Ändringslogg

#### 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))
 * Höj den minsta WP-versionen som krävs till 6.4. ([1076](https://github.com/WordPress/performance/pull/1076))

#### 0.1.0

 * Första utgåvan.

## Ideellt tillägg

Detta tillägg är utvecklat och stöds av en community. [Bidra till detta tillägg](https://github.com/WordPress/performance)

## Meta

 *  Version **1.0.0-beta5**
 *  Senast uppdaterat **1 månad sedan**
 *  Aktiva installationer **60 000+**
 *  WordPress-version ** 6.6 eller senare **
 *  Testat upp till **7.0**
 *  PHP-version ** 7.2 eller senare **
 *  Språk
 * [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/) och [Vietnamese](https://vi.wordpress.org/plugins/embed-optimizer/).
 *  [Översätt till ditt språk](https://translate.wordpress.org/projects/wp-plugins/embed-optimizer)
 * Etiketter
 * [Embeds](https://sv.wordpress.org/plugins/tags/embeds/)[optimization-detective](https://sv.wordpress.org/plugins/tags/optimization-detective/)
   [performance](https://sv.wordpress.org/plugins/tags/performance/)
 *  [Avancerad vy](https://sv.wordpress.org/plugins/embed-optimizer/advanced/)

## Betyg

 3 av 5 stjärnor.

 *  [  1 5-stjärnig recension     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=5)
 *  [  0 4-stjärniga recensioner     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=4)
 *  [  0 3-stjärniga recensioner     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=3)
 *  [  0 2-stjärniga recensioner     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=2)
 *  [  1 1-stjärnig recension     ](https://wordpress.org/support/plugin/embed-optimizer/reviews/?filter=1)

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

[Se alla recensioner](https://wordpress.org/support/plugin/embed-optimizer/reviews/)

## Bidragande personer

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

## Support

Har du något att säga? Behöver du hjälp?

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