PHPackages                             grape-fluid/asset-loader - 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. grape-fluid/asset-loader

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

grape-fluid/asset-loader
========================

v0.7.1(3mo ago)19321BSD-3-ClausePHPPHP &gt;= 8.2

Since Mar 6Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/grape-fluid/asset-loader)[ Packagist](https://packagist.org/packages/grape-fluid/asset-loader)[ Docs](https://github.com/grape-fluid/asset-loader)[ RSS](/packages/grape-fluid-asset-loader/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (8)Versions (8)Used By (1)

GrapeFluid/AssetLoader [![](https://camo.githubusercontent.com/a647a231e2b4d42009bdd9c73de6511f8aaf89534b548eb9689f7afef31eb684/68747470733a2f2f646576656c6f706572732e677261706573632e637a2f6c6f676f5f696e6c696e652e706e67)](https://camo.githubusercontent.com/a647a231e2b4d42009bdd9c73de6511f8aaf89534b548eb9689f7afef31eb684/68747470733a2f2f646576656c6f706572732e677261706573632e637a2f6c6f676f5f696e6c696e652e706e67)
============================================================================================================================================================================================================================================================================================================================================================================================================================

[](#grapefluidassetloader-)

[![PHP from Packagist](https://camo.githubusercontent.com/13e68be8e3de2857a75c54259bc13fc7923fda93c835a9a48e25631ba92bb592/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grape-fluid/asset-loader)[![Build Status](https://camo.githubusercontent.com/489dc49efc2d0cee19719fca7d5ad3f5f0ff0f593078d17078108981dbf5a0f3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/grape-fluid/asset-loader)[![Code coverage](https://camo.githubusercontent.com/e8cac38c76656d6e30bdf0a6ad717dc75ff45897b33269ddc2643f9cc8c52b51/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/grape-fluid/asset-loader)[![Licence](https://camo.githubusercontent.com/88f28b0696aa01b76a3ff22b2d14167a12394f3505bf7c9bc5da3305b9dd1844/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grape-fluid/asset-loader)[![Downloads this Month](https://camo.githubusercontent.com/dbe502e1d46fce75d62799766d276d215c3be28744f58dc8dee3c86938081c92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grape-fluid/asset-loader)[![Downloads total](https://camo.githubusercontent.com/f5b1ad877ded47e53b4a7ce1d5bcddd26c6bbaa488d585eff3db8f0acd12eda2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grape-fluid/asset-loader)[![Latest stable](https://camo.githubusercontent.com/465cfda191c94f379de60157b720f638402d41ec142aa4f9844c655a2ccc24a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67726170652d666c7569642f61737365742d6c6f616465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grape-fluid/asset-loader)

Asset Loader for your Nette projects

Dependencies
------------

[](#dependencies)

RequireVersionPHP`>= 5.6`nette/application`^2.4`nette/di`^2.4`Require-devVersionnette/tester`^2.0`tracy/tracy`^2.4`Quickstart
----------

[](#quickstart)

1. Install **Asset Loader** with composer

    ```
    composer require grape-fluid/asset-loader

    ```
2. Register **extension** (in neon)

    ```
    extensions:
    	assets: Grapesc\GrapeFluid\AssetLoaderExtension

    ```
3. Set your **public directory** (mostly www) (in neon)

    ```
    assets:
    	config:
    		wwwDir: %appDir%/../www

    ```
4. Set-up your first package (see all options / features below)

    ```
    assets:
    	yourPackage:
    		js:
    			# will create file in wwwDir/assets/yourPackage/js/main.js
    			- %appDir%/modules/WebsiteModule/assets/js/main.js
    		css:
    			# will create file in wwwDir/assets/yourPackage/css/styles.css
    			- %appDir%/modules/StyleModule/assets/css/style.css
    			# you can also use external / remote assets
    			- 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.min.css'
    		copy:
    			# will copy all images from folder into wwwDir/assets/yourPackage/copy/
    			- %appDir%/modules/StyleModule/assets/images/*

    ```
5. Inject *AssetsControl* and create component in your **BasePresenter**

    ```
    /** @var \Grapesc\GrapeFluid\AssetsControl\AssetsControl @inject */
    public $assets;

    protected function createComponentAssets()
    {
    	return $this->assets;
    }

    ```
6. Render your assets in **template**

    ```
    {control assets:css}
    {control assets:js}

    ```

Multiple files
--------------

[](#multiple-files)

If you have too many files (for ex. scripts) that you want to include in your templates, or just want to copy whole directory (for ex. with images), you can use asterisk `*` character.

```
assets:
	yourPackage:
		js:
			- %appDir%/modules/WebsiteModule/assets/js/scripts/*

```

Custom destination
------------------

[](#custom-destination)

If you need, for any reason, copy file into public directory with custom name or custom directory, just specify asset as array. You can use `&` character that will be replaced with public assets directory folder.

```
assets:
	yourPackage:
		js:
			# [ source, destination ]
			- [ %appDir%/modules/WebsiteModule/assets/js/main.js, &/my/folder/test.js ]

```

You can also do the same with whole **directories**:

```
assets:
	yourPackage:
		js:
			# [ source, destination ]
			- [ %appDir%/modules/StyleModule/assets/images/*, &/images/ ]

```

Options
-------

[](#options)

Of course, quickstart doesn't do anything special but copy files and use them in your template files. But it's getting more interesting with these options.

### Limits

[](#limits)

You can limit **assets** by Nette-like links. By default all defined assets are enabled everywhere. **You can combine multiple limits.** By using limits Asset Loader will load only assets that matches your limit. You can easily create assets for backend / frontend, but also for sub-frontend modules, etc.

#### How to limit asset for **module**?

[](#how-to-limit-asset-for-module)

```
assets:
	yourPackage:
		limit:
			- ":Module:.*"

```

#### How to limit asset for multiple **presenters**?

[](#how-to-limit-asset-for-multiple-presenters)

```
assets:
	yourPackage:
		limit:
			- ":Module:Presenter:.*"
			- ":Module:AnotherPresenter:.*"

```

#### Limiting by access rights ($user-&gt;isAllowed())

[](#limiting-by-access-rights-user-isallowed)

```
assets:
	yourPackage:
		# Will call $user->isAllowed('homepage')
		- ['link' = ':Module:Presenter.*', 'auth' = 'homepage']

```

#### Limiting by custom options

[](#limiting-by-custom-options)

Create and define custom service that implements `\Grapesc\GrapeFluid\Options\IAssetOptions` interface as written below. **We are automatically registering these as services** sou you don't have to. **Inject through constructor** in these services also works. Now you are able to handle limits in any way you want. For example enable / disable assets from your back-office.

```
assets:
	config:
		options:
			# Must implement \Grapesc\GrapeFluid\Options\IAssetOptions
			- \Your\Class\That\Handles\SomeOptions
			- \Your\Class\That\Handles\AnotherOptions
	yourPackage:
		# Will call $class->getOption('inline.enabled') on every service
		- ['link' = ':Module:Presenter.*', 'option' = 'inline.enabled']

```

#### Using negation limit

[](#using-negation-limit)

Use `!` in front of limit

```
assets:
	yourPackage:
		limit:
			- "!:Module:Presenter:.*"

```

### Ordering

[](#ordering)

Sometimes, especially when using modules, it comes handy to sort / order your packages.

#### Start / End

[](#start--end)

```
assets:
	yourPackage:
		order: [start|end]

```

#### Before / After

[](#before--after)

```
assets:
	yourPackage:
		order:
			[before|after]: anotherPackageName

```

or

```
assets:
	yourPackage:
		order:
			type: [before|after]
			position: anotherPackageName

```

### Disabling

[](#disabling)

```
assets:
	yourPackage:
		[disable|disabled]: true

```

Debug
-----

[](#debug)

By default Asset Loader operates in production mode, you can override this with following:

```
assets:
	config:
		debug: true

```

When debug mode is one, Asset Loader watch files for changes and deploy them automatically. It also works if you add new files into your packages.

Other
-----

[](#other)

### Custom asset folder

[](#custom-asset-folder)

```
assets:
	config:
		assetsDir: customDirectoryName

```

### Directory permissions

[](#directory-permissions)

```
assets:
	config:
		dirPerm: 0511

```

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance78

Regular maintenance activity

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 55% 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 ~731 days

Total

5

Last Release

116d ago

PHP version history (2 changes)v0.5.0PHP &gt;= 5.6

v0.7.0PHP &gt;= 8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4996607?v=4)[Míra Jakeš](/maintainers/sparkcz)[@sparkcz](https://github.com/sparkcz)

---

Top Contributors

[![GEp1c](https://avatars.githubusercontent.com/u/16386245?v=4)](https://github.com/GEp1c "GEp1c (11 commits)")[![sparkcz](https://avatars.githubusercontent.com/u/4996607?v=4)](https://github.com/sparkcz "sparkcz (9 commits)")

---

Tags

assetsfluid-cmsnetteassetsgrape-fluidfluid-cms

### Embed Badge

![Health badge](/badges/grape-fluid-asset-loader/health.svg)

```
[![Health](https://phpackages.com/badges/grape-fluid-asset-loader/health.svg)](https://phpackages.com/packages/grape-fluid-asset-loader)
```

###  Alternatives

[janmarek/webloader

Tool for loading or deploying CSS and JS files into web pages

114517.9k14](/packages/janmarek-webloader)

PHPackages © 2026

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