PHPackages                             mindkomm/theme-lib-script-loader-tags - 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. mindkomm/theme-lib-script-loader-tags

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

mindkomm/theme-lib-script-loader-tags
=====================================

Async and defer attribute helper tags for enqueueing scripts in WordPress themes

1.2.1(3y ago)101.3k2[1 issues](https://github.com/mindkomm/theme-lib-script-loader-tags/issues)MITPHPPHP &gt;=7.0.0

Since Feb 13Pushed 1y ago5 watchersCompare

[ Source](https://github.com/mindkomm/theme-lib-script-loader-tags)[ Packagist](https://packagist.org/packages/mindkomm/theme-lib-script-loader-tags)[ RSS](/packages/mindkomm-theme-lib-script-loader-tags/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)DependenciesVersions (5)Used By (0)

Script Loader Tags
==================

[](#script-loader-tags)

Helper functionality for enqueueing scripts in WordPress themes with the following `` tag attributes, because WordPress doesn’t support that for `wp_register_script()` or `wp_enqueue_script()`:

- `async`
- `defer`
- `nomodule`
- `type="module"`

WordPress doesn’t provide a default way to enqueue scripts with the above attributes. This package

- Adds a [`script_loader_tag`](https://developer.wordpress.org/reference/hooks/script_loader_tag/) filter to make it possible for you to set async and defer attributes through the name of the script that should be enqueued.
- Adds a `update_script_tag()` function so you can control how scripts are loaded, when you don’t have control over the name of the handle the script is using.

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

[](#installation)

You can install the package with Composer:

```
composer require mindkomm/theme-lib-script-loader-tags
```

Usage
-----

[](#usage)

### Use name suffixes

[](#use-name-suffixes)

Append any of the following suffixes to the name of your script to automatically set the attribute:

- `|async` for an `async` attribute
- `|defer` for a `defer` attribute
- `|nomodule` for a `nomodule` attribute
- `|module` for `type="module"` attribute

```
add_action( 'wp_enqueue_scripts', function() {
    // Load Picturefill asynchronously.
    wp_enqueue_script(
        'js-picturefill|async',
        get_theme_file_uri( 'build/js/picturefill.js' )
    );
} );
```

This will produce the following output:

```

```

It’s also possible to chain more than one suffix.

```
add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_script(
        'js-app|module|async',
        get_theme_file_uri( 'build/js/app.js' )
    );
} );
```

### Use a function

[](#use-a-function)

You can use the `update_script_tag()` function to set a filter that adds the attributes.

```
add_action( 'wp_enqueue_scripts', function() {
    // Load Picturefill asynchronously.
    wp_enqueue_script(
        'js-picturefill',
        get_theme_file_uri( 'build/js/picturefill.js' )
    );

    update_script_tag( 'js-picturefill', 'async' );
} );
```

It‘s also possible to add more than one handle and/or attribute if you pass an array:

```
// Multiple attributes.
update_script_tag( 'js-app', [ 'async', 'module' ] );

// Multiple handles.
update_script_tag( [ 'js-frontpage', 'js-app' ], 'async' );
```

This function is useful

- if you want to change the method of an existing script that you didn’t enqueue yourself.
- if you use `wp_register_script()`, where you shouldn’t add suffixes to the script handle.

Support
-------

[](#support)

This is a library that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 87.5% 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 ~607 days

Total

4

Last Release

1239d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2084481?v=4)[Lukas Gächter](/maintainers/gchtr)[@gchtr](https://github.com/gchtr)

---

Top Contributors

[![gchtr](https://avatars.githubusercontent.com/u/2084481?v=4)](https://github.com/gchtr "gchtr (7 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")

### Embed Badge

![Health badge](/badges/mindkomm-theme-lib-script-loader-tags/health.svg)

```
[![Health](https://phpackages.com/badges/mindkomm-theme-lib-script-loader-tags/health.svg)](https://phpackages.com/packages/mindkomm-theme-lib-script-loader-tags)
```

###  Alternatives

[deliciousbrains/wp-post-series

WordPress library for adding a series support to posts.

103.2k](/packages/deliciousbrains-wp-post-series)

PHPackages © 2026

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