A
A
Albert Tobacco2015-04-21 13:21:06
JavaScript
Albert Tobacco, 2015-04-21 13:21:06

I need to asynchronously load a script that will be executed after that in Yii 2. How can I achieve this (without jQuery)?

I need to asynchronously load a script to be executed after that in Yii 2 . How can this be achieved (without jQuery)?
I would be grateful for ideas.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Shatokhin, 2015-04-21
@iShatokhin

I don't know how Yii 2 uses scripts, but you can download it like this:

var s = document.createElement('script');
s.src = '/script.js'; // путь до нужного скрипта
s.async = true;
s.onload = s.onreadystatechange = function() {} // функция сработает сразу после загрузки скрипта
document.head.appendChild(s);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question