PHPackages                             ralfhortt/wp-assets - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ralfhortt/wp-assets

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ralfhortt/wp-assets
===================

A helper package for working with the WordPress assets

3.1.0(1w ago)01.9k2MITPHPPHP &gt;=8.2CI passing

Since Apr 2Pushed 1w ago1 watchersCompare

[ Source](https://github.com/Horttcore/wp-assets)[ Packagist](https://packagist.org/packages/ralfhortt/wp-assets)[ RSS](/packages/ralfhortt-wp-assets/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (6)Versions (12)Used By (2)

WP Assets
=========

[](#wp-assets)

[![CI](https://github.com/Horttcore/wp-assets/actions/workflows/ci.yml/badge.svg)](https://github.com/Horttcore/wp-assets/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/62dd94dce83295e6aec53e24367e911c749cc7433dbb737e4fc21038e5728a76/68747470733a2f2f706f7365722e707567782e6f72672f72616c66686f7274742f77702d6173736574732f762f737461626c65)](https://packagist.org/packages/ralfhortt/wp-assets)[![License](https://camo.githubusercontent.com/e39c615a730348e94468995297f561a74cf2c32456edfda3f30ea40ed1a08914/68747470733a2f2f706f7365722e707567782e6f72672f72616c66686f7274742f77702d6173736574732f6c6963656e7365)](https://packagist.org/packages/ralfhortt/wp-assets)[![PHP Version Require](https://camo.githubusercontent.com/161c0aed88f191783776a95aacbb0552bb659907367322d9e28ddd18e07debb8/68747470733a2f2f706f7365722e707567782e6f72672f72616c66686f7274742f77702d6173736574732f726571756972652f706870)](https://packagist.org/packages/ralfhortt/wp-assets)

A small helper package for registering and enqueuing WordPress scripts and styles.

Requirements
------------

[](#requirements)

- PHP `>= 8.2`
- WordPress (functions used at runtime)

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

[](#installation)

```
composer require ralfhortt/wp-assets
```

Documentation
-------------

[](#documentation)

### Scripts

[](#scripts)

```
use RalfHortt\Assets\Script;
use RalfHortt\Assets\AdminScript;
use RalfHortt\Assets\EditorScript;
use RalfHortt\Assets\LoginScript;

new Script(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = null, array|bool $args = []);
new AdminScript(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = null, array|bool $args = []);
new EditorScript(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = null, array|bool $args = []);
new LoginScript(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = null, array|bool $args = []);
```

### Inline scripts

[](#inline-scripts)

```
use RalfHortt\Assets\InlineScript;

new InlineScript(string $handle, string $data, string $position = 'after');
```

### Styles

[](#styles)

```
use RalfHortt\Assets\Style;
use RalfHortt\Assets\AdminStyle;
use RalfHortt\Assets\EditorStyle;
use RalfHortt\Assets\LoginStyle;
use RalfHortt\Assets\PrintStyle;

new Style(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = true, string $media = 'all');
new AdminStyle(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = true, string $media = 'all');
new EditorStyle(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = true, string $media = 'all');
new LoginStyle(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = true, string $media = 'all');
new PrintStyle(string $handle, string $source = '', array $dependencies = [], string|bool|null $version = true, string $media = 'all');
```

Pass absolute asset URLs as `$source` (for example from `get_stylesheet_directory_uri()` or `plugins_url()`). Local URL detection supports multisite, `home`/`siteurl` mismatches, and http/https differences so cache-busting via `filemtime` keeps working.

Usage
-----

[](#usage)

```
use RalfHortt\Assets\Style;
use RalfHortt\Assets\InlineScript;
use RalfHortt\Assets\LoginStyle;

(new Style('my-theme', get_stylesheet_directory_uri() . '/theme.css'))->register();

(new InlineScript('my-theme', 'const ThemeName = "Awesome";'))->register();

// Reuse a registered handle on another hook
(new Style('my-theme'))->register();
(new LoginStyle('my-theme'))->register();
```

```
use RalfHortt\Assets\Script;

(new Script(
    'my-theme',
    get_stylesheet_directory_uri() . '/app.js',
    dependencies: ['wp-element'],
    version: true,
    args: ['strategy' => 'defer'],
))->register();
```

Development
-----------

[](#development)

```
composer install
composer lint
composer test
```

- `composer lint` — PHPStan (level max) with WordPress stubs
- `composer test` — Pest suite for URL/path/version resolution

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance98

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% 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 ~334 days

Recently: every ~217 days

Total

9

Last Release

10d ago

Major Versions

1.1.0 → 2.02020-03-27

2.2.2 → 3.0.02024-11-06

PHP version history (2 changes)2.2.1PHP &gt;=8

3.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/45d54752dcf3da868ffe4a5ad2b876d6acb911fd914700b52e4d4777ff7d4a02?d=identicon)[Ralf Hortt](/maintainers/Ralf%20Hortt)

---

Top Contributors

[![Horttcore](https://avatars.githubusercontent.com/u/503252?v=4)](https://github.com/Horttcore "Horttcore (24 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ralfhortt-wp-assets/health.svg)

```
[![Health](https://phpackages.com/badges/ralfhortt-wp-assets/health.svg)](https://phpackages.com/packages/ralfhortt-wp-assets)
```

###  Alternatives

[magepal/magento2-cataloglazyload

Improve the load time of your Magento 2 categories pages by loading your images on demand with our Lazy Load Extension

5864.9k](/packages/magepal-magento2-cataloglazyload)[lamoda/enum-bundle

Utility wrapper around PHP-enum

101.6k](/packages/lamoda-enum-bundle)

PHPackages © 2026

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