PHPackages                             wearerequired/h2push - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. wearerequired/h2push

ActiveWordpress-plugin[HTTP &amp; Networking](/categories/http)

wearerequired/h2push
====================

Sends Link headers to bring HTTP/2 Server Push for scripts and styles to WordPress.

2.2.1(5mo ago)515.9k↓33.3%[5 PRs](https://github.com/wearerequired/h2push/pulls)GPL-2.0-or-laterPHPPHP &gt;=7.4CI passing

Since Oct 6Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/wearerequired/h2push)[ Packagist](https://packagist.org/packages/wearerequired/h2push)[ Docs](https://github.com/wearerequired/h2push)[ RSS](/packages/wearerequired-h2push/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (14)Used By (0)

HTTP/2 Server Push
==================

[](#http2-server-push)

[![PHPUnit Tests](https://github.com/wearerequired/h2push/actions/workflows/phpunit-tests.yml/badge.svg)](https://github.com/wearerequired/h2push/actions/workflows/phpunit-tests.yml) [![Coding Standards](https://github.com/wearerequired/h2push/actions/workflows/coding-standards.yml/badge.svg)](https://github.com/wearerequired/h2push/actions/workflows/coding-standards.yml)

Sends Link headers to bring HTTP/2 Server Push for scripts and styles to WordPress. Falls back to `` element if headers are already sent.
Provides filters to customize and extend the resources to push.

[![Screenshot](https://user-images.githubusercontent.com/617637/31279476-7c3dffd6-aaa9-11e7-91d8-57ec4435d067.png)](https://user-images.githubusercontent.com/617637/31279476-7c3dffd6-aaa9-11e7-91d8-57ec4435d067.png)

Installation
------------

[](#installation)

Install the latest version with

```
composer require wearerequired/h2push
```

The plugin requires at least PHP 7.4 and WordPress 5.6.

Hooks reference
---------------

[](#hooks-reference)

### `h2push.as_header`

[](#h2pushas_header)

By default the plugin will use the Link header if no headers are sent yet and falls back to the `` element. To change this behavior you can use the `h2push.as_header` filter. Example:

```
// Force H2 Push to always use the `` element.
add_filter( 'h2push.as_header', '__return_false' );
```

This filter is also useful if the server doesn't support HTTP/2 yet and you still want to benefit from preloading.

### `h2push.push_resources`

[](#h2pushpush_resources)

By default the plugin collects all enqueued scripts and styles which are have been registered before or at the `wp_enqueue_scripts` hook. The `h2push.push_resources` filters allows to customize the list of resources. Example:

```
/**
 * Add web font and hero image to the list of resources to push/preload.
 *
 * @param array $resources List of resources.
 * @return array List of resources.
 */
function my_theme_push_resources( array $resources ): array {
	$relative_template_directory_uri = wp_parse_url( get_template_directory_uri(), PHP_URL_PATH );

	// Push web font.
	$resources[] = [
		'href' => $relative_template_directory_uri . '/assets/fonts/fancy.woff2',
		'as'   => 'font',
		'type' => 'font/woff2',
		'crossorigin',
	];

	if ( is_front_page() && ! is_paged() ) {
		// Push hero image.
		$resources[] = [
			'href' => $relative_template_directory_uri . '/assets/images/hero.webp',
			'as'   => 'image',
			'type' => 'image/webp',
		];
	}

	return $resources;
}
add_filter( 'h2push.push_resources', 'my_theme_push_resources' );
```

### `h2push.is_allowed_push_host`

[](#h2pushis_allowed_push_host)

By default the plugin only sends push requests for local resources where the asset URL matches the home URL. To change this behavior you can use the `h2push.is_allowed_push_host` filter. Example:

```
/**
 * Allow resources from example.org to be pushed/preloaded too.
 *
 * @param bool   $is_allowed Whether the host should be allowed. Default true for local resources.
 * @param string $host       The host name of the resource.
 * @return bool Whether the host should be allowed.
 */
function my_theme_is_allowed_push_host( $is_allowed, $host ) {
	return $is_allowed || 'example.org' === $host;
}
add_filter( 'h2push.is_allowed_push_host', 'my_theme_is_allowed_push_host' );
```

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity29

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 88.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~425 days

Recently: every ~472 days

Total

8

Last Release

168d ago

Major Versions

1.3.0 → 2.0.02021-04-21

PHP version history (3 changes)1.0.0PHP &gt;=7.0

1.3.0PHP &gt;=7.1

2.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1446895?v=4)[required](/maintainers/wearerequired)[@wearerequired](https://github.com/wearerequired)

---

Top Contributors

[![ocean90](https://avatars.githubusercontent.com/u/617637?v=4)](https://github.com/ocean90 "ocean90 (53 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![grappler](https://avatars.githubusercontent.com/u/1785641?v=4)](https://github.com/grappler "grappler (2 commits)")

---

Tags

wordpresswordpress-pluginwordpresshttp2server-push

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wearerequired-h2push/health.svg)

```
[![Health](https://phpackages.com/badges/wearerequired-h2push/health.svg)](https://phpackages.com/packages/wearerequired-h2push)
```

###  Alternatives

[openswoole/core

Openswoole core library

181.1M32](/packages/openswoole-core)[swoole/etcd-client

Grpc PHP Client base on Swoole Http2 Coroutine

1973.2k1](/packages/swoole-etcd-client)[melbahja/http2-pusher

PHP Http2 Server Pusher

2829.9k1](/packages/melbahja-http2-pusher)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
