V
V
Vadim Timoshenko2020-02-07 17:22:48
1C-Bitrix
Vadim Timoshenko, 2020-02-07 17:22:48

How to include js at the end of 1C-Bitrix template?

I use Asset::getInstance()->addJs() to include scripts in the template. In footer.php file.
As far as I understand - wherever I write:

Asset::getInstance()->addJs("/local/templates/main/js/sceneIndex.js");


The script will be connected in the header (where I have $APPLICATION->ShowHead()). And before loading the DOM.

The documentation says:


Parameter $additional
By default, false, that is, the scripts are connected after connecting the core scripts and the site template. If true, scripts connected by this method will be added to the end of the current script output target. Those. if they belong to the core, then after the entire core, if they belong to the template, then after the site template and they will be able to influence it.


I write:
Asset::getInstance()->addJs("/local/templates/main/js/sceneIndex.js", true);


But the script is still in the header.
If you read into ".. if they refer to the core, then after the entire core, if to the template, then after the template .." then apparently I have after the kernel, and not after the template. How can I make the script load after the template?

Am I not writing script connection there?
Where is the best place to connect them?
Now I am connecting here /local/templates/index/footer.php.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail, 2020-02-07
@PbI6A_KuT

you don't read correctly

will be added to the end of the current script output target.
those. you choose after the core scripts or after the template scripts,
if you want to go to the end of the page, then in the admin panel in the settings of the main module, check the corresponding box

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question