PHPackages                             markocupic/contao-twig-assets - 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. [Templating &amp; Views](/categories/templating)
4. /
5. markocupic/contao-twig-assets

ActiveContao-bundle[Templating &amp; Views](/categories/templating)

markocupic/contao-twig-assets
=============================

Load link- or script-assets to the document from inside your TWIG template.

1.1.2(1y ago)310.8k—7.4%13GPL-3.0-or-laterPHPPHP ^8.1

Since Nov 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/markocupic/contao-twig-assets)[ Packagist](https://packagist.org/packages/markocupic/contao-twig-assets)[ RSS](/packages/markocupic-contao-twig-assets/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (6)Used By (13)

[![Alt text](docs/logo.png?raw=true "logo")](docs/logo.png?raw=true)

Contao Twig Assets
==================

[](#contao-twig-assets)

Adding assets via the global array `$GLOBALS` is no more possible when using TWIG templates. This Bundle for the Contao CMS provides **5 TWIG functions** to load assets from inside your **TWIG template**.

Usage
-----

[](#usage)

Each of these five functions take two parameters e.g. addJavascriptResource($resource\_path, $position) The first parameter '$resource\_path' is mandatory, while the second parameter '$position' is optional.

**Default usage:**

```
{# Inside your twig template: #}

{% do addJavascriptResource('bundles/contaofoobarplugin/js/my.js|static') %}
{# Same as $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/contaofoobarplugin/js/my.js|static'; #}

```

**Set a javascript resource at a fixed position or replacing it:**

```
{# Inside your twig template: #}

{% do addJavascriptResource('bundles/contaofoobarplugin/js/my.js|static', 2) %}
{# Same as $GLOBALS['TL_JAVASCRIPT'][2] = 'bundles/contaofoobarplugin/js/my.js|static'; #}

```

Overview
--------

[](#overview)

```
{# Inside your twig template: #}

{% do addJavascriptResource('bundles/contaofoobarplugin/js/my.js|static') %}
{# Same as $GLOBALS['TL_JAVASCRIPT'][] = 'bundles/contaofoobarplugin/js/my.js|static'; #}

{% do addCssResource('bundles/contaofoobarplugin/css/style.css|static') %}
{# Same as $GLOBALS['TL_CSS'][] = 'bundles/contaofoobarplugin/css/style.css|static'; #}

{% do addHtmlToHead('') %}
{# Same as $GLOBALS['TL_HEAD'][] = ''; #}

{% do addHtmlToBody('') %}
{# Same as $GLOBALS['TL_BODY'][] = ''; #}

{% do addMootoolsResource('') %}
{# Same as $GLOBALS['TL_MOOTOOLS'][] = ''; #}

```

File make time
--------------

[](#file-make-time)

Use the third paramter (boolean true) to add the file make time of a script or css asset to ensure that clients always receive the latest version of the asset, when it changes.

```
{# Inside your twig template: #}

{% do addCssResource('bundles/foobar/css/my.css',null,true) %}
{# --> bundles/foobar/css/my.css?_ver=1709332057 #}

{% do addJavascriptResource('bundles/contaofoobarplugin/js/my.js',null,true) %}
{# --> bundles/contaofoobarplugin/js/my.js?_ver=1709332057 #}

```

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity59

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

Total

5

Last Release

555d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1525166?v=4)[Marko Cupic](/maintainers/markocupic)[@markocupic](https://github.com/markocupic)

---

Top Contributors

[![markocupic](https://avatars.githubusercontent.com/u/1525166?v=4)](https://github.com/markocupic "markocupic (10 commits)")

---

Tags

twigcontaoassetsglobalsTL\_JAVASCRIPTTL\_CSSTL\_HEADTL\_MOOTOOLSTL\_BODY

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/markocupic-contao-twig-assets/health.svg)

```
[![Health](https://phpackages.com/badges/markocupic-contao-twig-assets/health.svg)](https://phpackages.com/packages/markocupic-contao-twig-assets)
```

###  Alternatives

[odan/twig-assets

Caching and compression for Twig assets (JavaScript and CSS).

2223.0k4](/packages/odan-twig-assets)[contao-themes-net/mate-theme-bundle

mate theme bundle for Contao 5

1219.2k1](/packages/contao-themes-net-mate-theme-bundle)

PHPackages © 2026

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