LateNight Coding

  • Increase font size
  • Default font size
  • Decrease font size
Home FAQs Developers How can I add a script declaration in document header?

How can I add a script declaration in document header?

You can use JHTML::script() to include a script declaration between the <head> and </head> tags of a Joomla! generated page.

This is useful for modules or components that need custom scripts to work.

Syntax

JHTML::script(file, path, mootools);

  • file script file name
  • path path to the folder where script is located. It can be absolute or relative to Joomla! folder
  • mootools if true Mootools framework will be loaded.

Example

Let's say you are developing a module called mod_mymodule and you want to add a declaration for a script myscript.js located in [Joomla! folder]/modules/mod_mymodule/js, here is the code you need to use

JHTML::script('myscript.js','modules/mod_mymodule/js/');

When, as in this example, path doesn't start with http:// it's considered relative to Joomla! folder.

 
English Italiano
Support the development of our open source products.

Mootools

GNU GPL License Version 3

120x60c