Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
About the Author
About the Reviewers

Adding CSS and JS in your module

We will now look at two new functions, which will permit you to add CSS and JS in your module:

$this->context->controller->addCSS($this->_path.'views/css/mymodcomments.css', 'all');

You will probably ask yourself why use these methods when you can just add the link to your CSS and JS directly in your module templates. The reasons are as follows:

  • It makes your module compliant with the CCC option in Advanced parameters | Performance. This option is used to dynamically merge all the CSS files and JS files together.

  • It avoids including the same JS file several times (for example, if you need a specific jQuery UI plugin already used by another module).


You can also add the JS file, which is in the common JS directory:


Or you can add the jQuery UI plugin: