Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
Sign in to follow this  

Guidance needed on Asset Management - adding JS to the DOM - Front Back Head Bottom


I am absolutely not clear on what the "best" or "correct" way is for me to add JS files to my modules.

I suppose this problem can be categorized as Asset Management.

There are several variables: 

  • Sometimes JS should be included in the header, sometimes before the body tag closes.
  • Sometimes my JS has a dependency, which needs to be loaded BEFORE my JS file (e.g. jQuery)
  • Sometimes my module has a controller from which it can load JS, sometimes it's only a hook.
  • Sometimes I need JS on the front office (customer area) sometimes in the back office (admin area)

Personally I think jQuery should be included by default, but I understand the reasons why it might not be.

Over the years, I've quite a few methods of how to get things to work:

public function hookDisplayBackOfficeHeader($params){


protected function addBackOfficeMedia(){


public function setMedia(){


And probably a couple of other ways, including to just slap it into the tpl file... I've been really confused on this for a long time! 

PrestaShop 1.7 actually introduced something super useful:

public function hookActionFrontControllerSetMedia(){
		  'position' => 'head|bottom', //SO USEFUL!!
		  'priority' => 50, //SO USEFUL!!
		  'inline' => false,
		  'server' => 'remote',
		  'attributes' => 'async',

Source: https://devdocs.prestashop.com/1.7/themes/getting-started/asset-management/

I thought this was a really nice, clean, long needed solution for this problem.

Literally, this was probably the only good thing about PS 1.7 hahah


What's the status quo about that on Thirtybees? Is there any conclusive documentation available about this?

Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...