# wp_lazy_loading_enabled()

URL: https://chugunov.pro/api-wordpress/functions/wp_lazy_loading_enabled/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 5.5.0.

## Сигнатура

```php
wp_lazy_loading_enabled( string $tag_name, string $context ): bool
```

## Описание

Определяет, следует ли добавлять атрибут `loading` к указанному тегу в указанном контексте.

## Параметры

- `$tag_name` `string` — обязательный. Имя тега.
- `$context` `string` — обязательный. Дополнительный контекст, например имя текущего фильтра или имя функции, откуда был совершён вызов.

## Возвращаемое значение

`bool`

## Исходный код

Файл: `wp-includes/media.php:1843`

```php
function wp_lazy_loading_enabled( $tag_name, $context ) {
	/*
	 * By default add to all 'img' and 'iframe' tags.
	 * See https://html.spec.whatwg.org/multipage/embedded-content.html#attr-img-loading
	 * See https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-loading
	 */
	$default = ( 'img' === $tag_name || 'iframe' === $tag_name );

	/**
	 * Filters whether to add the `loading` attribute to the specified tag in the specified context.
	 *
	 * @since 5.5.0
	 *
	 * @param bool   $default  Default value.
	 * @param string $tag_name The tag name.
	 * @param string $context  Additional context, like the current filter name
	 *                         or the function name from where this was called.
	 */
	return (bool) apply_filters( 'wp_lazy_loading_enabled', $default, $tag_name, $context );
}
```

## История изменений

- 5.7.0 — Now returns true by default for iframe tags.
- 5.5.0 — Introduced.

## Связанные

Использует: [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`wp_get_loading_optimization_attributes`](https://chugunov.pro/api-wordpress/functions/wp_get_loading_optimization_attributes/), [`wp_img_tag_add_loading_optimization_attrs`](https://chugunov.pro/api-wordpress/functions/wp_img_tag_add_loading_optimization_attrs/), [`wp_filter_content_tags`](https://chugunov.pro/api-wordpress/functions/wp_filter_content_tags/), `WP_Widget_RSS::widget`, [`wp_admin_bar_my_sites_menu`](https://chugunov.pro/api-wordpress/functions/wp_admin_bar_my_sites_menu/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_lazy_loading_enabled/
