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(9mo ago)122mitPHPPHP ^8.0|^8.1|^8.2|^8.3|^8.4

Since Feb 22Pushed 9mo 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 yesterday

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

41

—

FairBetter than 87% of packages

Maintenance58

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity78

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

274d 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

[iazaran/smart-cache

Smart Cache is a caching optimization package designed to enhance the way your Laravel application handles data caching. It intelligently manages large data sets by compressing, chunking, or applying other optimization strategies to keep your application performant and efficient.

21114.2k](/packages/iazaran-smart-cache)[phpfastcache/phpssdb

PHP SSDB Driver for phpFastCache

14736.9k1](/packages/phpfastcache-phpssdb)[rapidwebltd/rw-file-cache

RW File Cache is a PHP File-based Caching Library. Its syntax is designed to closely resemble the PHP memcache extension.

15196.8k7](/packages/rapidwebltd-rw-file-cache)[yuzuru-s/redis-recommend

Wrapping Redis's sorted set APIs for specializing recommending operations.

392.9k](/packages/yuzuru-s-redis-recommend)[ichhabrecht/intcache

Turn uncachable page objects into cacheable links

193.9k](/packages/ichhabrecht-intcache)

PHPackages © 2026

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