js_tag — Get a tag for including a local JavaScript file.

Asset-related functions

Summary

The js_tag() helper function retrieves JavaScript files located within the /javascripts/ folder
of a theme. By using js_tag(), the relative path to the file is dynamically generated for each page.

Note

The queue_js_file helper is preferred to this one for most use cases. Normally, you should only continue to use this helper when you want to output an inline script in the body of the page.

js_tag($file, $dir = 'javascripts', $version = OMEKA_VERSION)

Get a tag for including a local JavaScript file.

Parameters:
  • $file (string) – The name of the file, without .js extension.
  • $dir (string) – The directory in which to look for javascript files. Recommended to leave the default value.
  • $version (mixed) – Version number. By default OMEKA_VERSION.
Returns:

string

Usage

Examples

Add a link to a javascript file located in the theme’s javascripts directory. Use when you need to load js files outside of the head.php file.

<?php echo js_tag('items'); ?>

See Also