js($path, $async = false)

Creates a script tag to load a javascript file

Example

Creating a single script tag

<?php echo js('assets/js/site.js') ?>

Creating multiple script tags

<?php echo js(array(
  'assets/js/jquery.js',
  'assets/js/jquery.ui.js',
  'assets/js/site.js',
)) ?>

Autoloading template specific script files

<?php echo js('@auto') ?>

Template specific js files must be located in /assets/js/templates and named like the template.

Template JS file
/site/templates/project.php /assets/js/templates/project.js
/site/templates/home.php /assets/js/templates/home.js
/site/templates/blog.php /assets/js/templates/blog.js

Async

If you want the js files to be loaded asynchronously (if supported by the browser), you can set a second parameter as true:

<?php echo js('assets/js/site.js', true) ?>