PHPackages                             felixl7/laravel-asset - 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. felixl7/laravel-asset

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

felixl7/laravel-asset
=====================

CDN Helper

v1.2.0(4y ago)15PHPPHP &gt;=7.3.0

Since Aug 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/FelixL7/laravel-asset)[ Packagist](https://packagist.org/packages/felixl7/laravel-asset)[ RSS](/packages/felixl7-laravel-asset/feed)WikiDiscussions main Synced 2d ago

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

laravel-asset
=============

[](#laravel-asset)

You can use this package to get any Frontend Asset from any CDN you want in a laravel-like notation.

```
use FelixL7\Asset\Facades\Asset;

Asset::bootstrap()->min()->js();
//
```

With this package come 3 CDN implementations:

- [cdnjs](https://cdnjs.com/)
- [jsDelivr](https://www.jsdelivr.com/)
- [UNPKG](https://unpkg.com/)

And 3 Libraries:

- [Bootstrap](https://getbootstrap.com/)
- [jQuery](https://jquery.com/)
- [Swiper](https://swiperjs.com/)

You can use these implementations to implement other CDNs and libraries, you want to use.
It's really simple to add new. Try it out!

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

[](#installation)

```
composer require felixl7/laravel-asset
```

Register Libs
-------------

[](#register-libs)

You can register libraries everywhere with the register method.

```
use FelixL7\Asset\Facades\Asset;
use FelixL7\Asset\Libs\Bootstrap;
use FelixL7\Asset\Libs\JQuery;
use FelixL7\Asset\Libs\Swiper;

Asset::register([
    Bootstrap::class,
    JQuery::class,
    Swiper::class
]);
```

Configuration
-------------

[](#configuration)

```
use FelixL7\Asset\CDNs\Cdnjs;
use FelixL7\Asset\CDNs\JsDelivr;

return [
    //main cdn -> required
    'cdn' => Cdnjs::class,

    //libraries
    'libs' => [
        //libName, must match $libName in library
        'bootstrap' => [
            //use asset version -> required
            'version' => '5.0.1',
            //overwrite main cdn
            'cdn' => JsDelivr::class,
        ],
        'jquery' => [
            'version' => '3.6.0',
        ],
        'swiper' => [
            'version' => '6.5.8',
        ],
    ]
];
```

You can use following settings in your lib or globally: min, cache, cache\_config\_version, loading\_attribute. These will override the default settings for this attributes.

```
use FelixL7\Asset\CDNs\Cdnjs;
use FelixL7\Asset\CDNs\JsDelivr;

return [
    //main cdn -> required
    'cdn' => Cdnjs::class,
    //load only minified assets
    'min' => true,

    //libraries
    'libs' => [
        //libName, must match $libName in library
        'bootstrap' => [
            //use asset version -> required
            'version' => '5.0.1',
            //overwrite main cdn
            'cdn' => JsDelivr::class,
            //caching of assets will be disabled
            'cache' => false,
            //use cache_version, if not configured cache_version will be 1
            'cache_config_version' => true,
            //Load assets asynchronous
            'loading_attribute' => 'async',
        ],
        'jquery' => [
            'version' => '3.6.0',
        ],
        'swiper' => [
            'version' => '6.5.8',
        ],
    ]
];
```

Usage
-----

[](#usage)

If you registered the library you can use it like:

```
use FelixL7\Asset\Facades\Asset;

Asset::bootstrap()->min()->async()->disableCacheWithConfigVersion()->js();
//

Asset::bootstrap()->min()->css();
//
```

Or in Blade templates:

```
@inject('asset', FelixL7\Asset\Asset::class)

{{$asset->bootstrap()->min()->async()->disableCacheWithConfigVersion()->js()}}
```

### Available Methods

[](#available-methods)

```
use FelixL7\Asset\Facades\Asset;

// Example
//Asset::bootstrap()->js()
//

//min()
Asset::bootstrap()->min()->js();
//

//readable()
Asset::bootstrap()->readable()->js();
Asset::bootstrap()->min()->readable()->js();
//

//version(string $version)
Asset::bootstrap()->version('4.0.0')->js();
//

//configVersion()
//Version from config file
Asset::bootstrap()->configVersion()->js();
Asset::bootstrap()->version('4.0.0')->configVersion()->js();
//

//disableCache()
Asset::bootstrap()->disableCache()->js();
//

//disableCacheWithConfigVersion()
Asset::bootstrap()->disableCacheWithConfigVersion()->js();
//

//enableCache()
Asset::bootstrap()->enableCache()->js();
Asset::bootstrap()->disableCache()->enableCache()->js();
//

//cdn(string $cdn)
Asset::bootstrap()->cdn(\FelixL7\Asset\CDNs\Cdnjs::class)->js();
//

//configCdn()
Asset::bootstrap()->configCdn()->js();
Asset::bootstrap()->cdn(\FelixL7\Asset\CDNs\Cdnjs::class)->configCdn()->js();
//

//hasCss() : bool
Asset::bootstrap()->hasCss();
//true

//hasJs() : bool
Asset::bootstrap()->hasJs();
//true
```

### Available CSS Methods

[](#available-css-methods)

```
//css()
Asset::bootstrap()->css();
//
//If hasCss() returns false, en empty string will be returned

//cssUrl()
Asset::bootstrap()->cssUrl();
//https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.css
//If hasCss() returns false, en empty string will be returned
```

### Available JS Methods

[](#available-js-methods)

```
//js()
Asset::bootstrap()->js();
//
//If hasJs() returns false, en empty string will be returned

//jsUrl()
Asset::bootstrap()->jsUrl();
//https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.js
//If hasJs() returns false, en empty string will be returned

//sync()
Asset::bootstrap()->sync()->js();
Asset::bootstrap()->defer()->sync()->js();
//

//async()
Asset::bootstrap()->async()->js();
Asset::bootstrap()->defer()->async()->js();
//

//defer()
Asset::bootstrap()->defer()->js();
Asset::bootstrap()->async()->defer()->js();
//
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

Total

4

Last Release

1696d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4bc9b1672a8a3b4121dd8a2cb5414d3c65730f614218986c9da1e245db67d936?d=identicon)[FelixL7](/maintainers/FelixL7)

---

Top Contributors

[![FelixL7](https://avatars.githubusercontent.com/u/22714206?v=4)](https://github.com/FelixL7 "FelixL7 (1 commits)")

### Embed Badge

![Health badge](/badges/felixl7-laravel-asset/health.svg)

```
[![Health](https://phpackages.com/badges/felixl7-laravel-asset/health.svg)](https://phpackages.com/packages/felixl7-laravel-asset)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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