M
M
Maxim Lagoysky2017-09-26 12:01:33
Yii
Maxim Lagoysky, 2017-09-26 12:01:33

How to make the js file load not after jq, but after a certain file of its own?

I have a separate js file on one page. I connect it like this.

<? $this->registerJsFile('@web/user/js/jquery.formstyler.js', ['depends' => [yii\web\JqueryAsset::className()]]); ?>

is it possible to somehow prescribe it so that it becomes dependent on another js file, for example main.js?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2017-09-26
@lagoy

is it possible to somehow prescribe it so that it becomes dependent on another js file, for example main.js?

out of the box it is impossible, you can only specify a dependency on a set of resources

I
Ilya Agafonov, 2017-09-26
@Tairesh

It is highly recommended to use asset bundles to register external JS files rather than registerJsFile() because these allow better flexibility and more granular dependency configuration. Also using asset bundles allows you to combine and compress multiple JS files, which is desirable for high traffic websites.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question