---
title: assets-push-bundle
description: 'Push CSS and JS from anywhere inside your Twig templates — flexible, no detours.'
---

assets-push-bundle was one of those projects where I thought: it's obvious that something like this should exist.

From inside a Twig partial, be able to say: this component needs this CSS and this JavaScript. And in the final HTML, the assets show up once, in the right place — not loaded globally for every page, but not manually stitched together either.

The foundation was [rybakit/twig-deferred-extension](https://github.com/rybakit/twig-deferred-extension). The extension gave me the deferred rendering I needed to collect the assets at the end of the render pass.

With Twig 4, the API changed. The deferred extension hasn't run cleanly since, several users have reported it ([Issue #20](https://github.com/rybakit/twig-deferred-extension/issues/20), [Issue #22](https://github.com/rybakit/twig-deferred-extension/issues/22)). The bug is known, a fix is not in sight.

As long as the extension doesn't work with modern Twig, I can't in good conscience recommend the bundle for new projects. The entry stays here anyway. The bundle worked, it was a clean solution to a real problem — and the standstill is not in my code.

If I were to build this again today, I'd either drop a small Twig extension directly into the project — or solve it declaratively via YAML, the way Sylius does it with its [Twig Hooks](https://stack.sylius.com/twig-hooks/getting-started).
