PHPackages                             rosswintle/statamic-asset-cache - 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. [Caching](/categories/caching)
4. /
5. rosswintle/statamic-asset-cache

ActiveStatamic-addon[Caching](/categories/caching)

rosswintle/statamic-asset-cache
===============================

Local caching for inclusion of JavaScript and CSS assets in Statamic (v3) projects

v4.0(5mo ago)122mitPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4

Since Feb 22Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/rosswintle/statamic-asset-cache)[ Packagist](https://packagist.org/packages/rosswintle/statamic-asset-cache)[ RSS](/packages/rosswintle-statamic-asset-cache/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

Statamic Asset Cache
====================

[](#statamic-asset-cache)

A Statamic addon that automates downloading CSS and JS assets from CDNs so that they can be self hosted.

This is a Statamic tag based on my [Laravel Asset Cache](https://github.com/rosswintle/laravel-asset-cache/) package.

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

[](#installation)

Use the following versions (I think - pre v3.x may not have been accurate):

- v4.x for Statamic 4.x/Laravel 9/10/11/12 on PHP 8.0/8.1/8.2/8.3/8.4
- v3.x for Statamic 3.3/Laravel 9 on PHP 8.0/8.1
- v2.x for Statamic 3.1/3.2/Laravel 8 on PHP 7/8.0
- v1.x for Statamic 3.0/Laravel 8 on PHP 7

Install the package with composer:

```
composer require rosswintle/statamic-asset-cache

```

Cached assets are stored in and served from the `public` file storage "disk". You will need to have symlinked your `public/storage` directory to `storage/app/public` as per the [Laravel docs](https://laravel.com/docs/6.x/filesystem#the-public-disk) using:

```
php artisan storage:link

```

Be sure to do this in ALL environments: local, staging, and production, if you haven't already.

Usage
-----

[](#usage)

The Statamic tag is:

```
{{ asset_cache package='' version='' file='' }}

```

- `package` is the name of an npm package (currently only npm is supported via jsdelivr.net)
- `version` is a version constraint such as `1.9.0`. Semantic versioning is assumed. You can use `1.9` to get the latest `1.9.x` version as per the [jsdelivr docs](https://www.jsdelivr.com/features) but this is not recommended in production environments
- `file` is the path and filename (with extension) for the asset that you want relative to the package's root. For example `dist/alpine.js`

The tag outputs the URL of the locally-cached file from the package.

Example:

```

```

You can also use this for CSS:

```

```

What does this do?
------------------

[](#what-does-this-do)

Using the tag:

- Downloads the asset from jsdelivr.net
- Caches it in your site's `public` directory
- Returns the URL of the cached, local asset

What problem does this solve?
-----------------------------

[](#what-problem-does-this-solve)

It saves you having to manually download assets and include them in your project if you want to host them locally.

There are [various reasons](https://csswizardry.com/2019/05/self-host-your-static-assets/) why you may want to do this, such as avoiding having your users tracked, to avoid depending on third-party CDNs and there are possible performance benefits too.

I'm also on a mission to ditch npm and build process from simple projects, so this bit of automation seemed useful.

If you dare specify an imprecise version constraint such as just `1.9` you can also get latest releases of dependencies without having to do anything! But all the big CDN's advise against this as it can break your site so use with **caution** and avoid in production environments!!

Compatibility
-------------

[](#compatibility)

This package was built for and tested with Statamic 3 (beta) and Laravel 6.x, but should work on newer versions.

Limitations
-----------

[](#limitations)

This is my first public package and Statamic addon. All sorts of things could be wrong! Please be gentle.

More limitations are given in the [package's readme](https://github.com/rosswintle/laravel-asset-cache/blob/master/README.md#limitations)

Roadmap
-------

[](#roadmap)

See the [package's roadmap](https://github.com/rosswintle/laravel-asset-cache/blob/master/README.md#roadmap)

Credits
-------

[](#credits)

- Thanks to [Marcel Pociot](https://twitter.com/marcelpociot) for his excellent [PHP Package Development](https://phppackagedevelopment.com/) course which helped me greatly in making this a package
- Thanks to [Ben Furfie](https://twitter.com/frontendben), [Ryan Chandler](https://twitter.com/ryangjchandler) and [Duncan McClean](https://twitter.com/damcclean) for encouragement and feedback and [Erin Dalzell](https://twitter.com/emd) for a bit of Statamic addon help.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity77

Established project with proven stability

 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 ~697 days

Total

4

Last Release

175d ago

Major Versions

v1.0 → v2.02021-04-19

v2.0 → v3.02022-04-03

v3.0 → v4.02025-11-15

PHP version history (4 changes)v1.0PHP ^7.1.3

v2.0PHP ^7.3 || ^8.0

v3.0PHP ^8.0 || ^8.1

v4.0PHP ^8.0|^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/dbfb2caf10c04f39a71681ef0d25874646a27b0f9692e3542f38db02b0dde319?d=identicon)[rosswintle](/maintainers/rosswintle)

---

Top Contributors

[![rosswintle](https://avatars.githubusercontent.com/u/1532368?v=4)](https://github.com/rosswintle "rosswintle (7 commits)")

### Embed Badge

![Health badge](/badges/rosswintle-statamic-asset-cache/health.svg)

```
[![Health](https://phpackages.com/badges/rosswintle-statamic-asset-cache/health.svg)](https://phpackages.com/packages/rosswintle-statamic-asset-cache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7431.3M3](/packages/wp-media-wp-rocket)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)

PHPackages © 2026

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