We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Async loading css/js with asset manager

Hello Guys,

I just have short question you may can answer me: Is it possible to load css/js files async with the asset manager? Is there any option?

What I want to have for output (with $asset->outputJs("js");) is something like e.g.:

<script async src="script.js" type="text/javascript"></script>

Thanks, Yannici



43.9k

Hi,

have a look at that thread



8.1k
edited Dec '14

Following https://developer.mozilla.org/en/docs/Web/HTML/Element/script

you can write :

->addJs("assets/scripts/app.js", true, false, ['async' => 'true'])

and check :

myscript = document.querySelector('script').async;