Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to include async or defer in volt syntax?

For example, if I have something like:

{{ javascript_include('third-party/proui/backend/js/vendors/modernizr-respond.min.js') }}

How do I add async or defer into this? I tried , 'async' : true but it didn't work.



35.1k
Accepted
answer

javascript_include has only 2 parameters: source and local (boolean value). Short answer you can't. But:

  1. You can create your own helper by following this steps: https://docs.phalconphp.com/en/latest/reference/tags.html#creating-your-own-helpers
  2. Why would you need a javascript async ? There is an interesting discussion about this subject here: https://css-tricks.com/async-attribute-scripts-bottom/

Good luck !

I see. Thanks alot.

javascript_include has only 2 parameters: source and local (boolean value). Short answer you can't. But:

  1. You can create your own helper by following this steps: https://docs.phalconphp.com/en/latest/reference/tags.html#creating-your-own-helpers
  2. Why would you need a javascript async ? There is an interesting discussion about this subject here: https://css-tricks.com/async-attribute-scripts-bottom/

Good luck !