SOLVED: Removing a line causes the browser to freeze

With this line removed from the code, the browser freezes, how come? How would I prevent that from ever happening?

Is the code written wrong where that is even able to happen in the first place?

apiIsReady = true; / Line Removed:

Try clicking on a play button on the image and the browser freezes.
https://jsfiddle.net/5umd9zfg/49/

apiIsReady = true; / Line Added:
https://jsfiddle.net/5umd9zfg/30/

I was just told this:

If you remove apiIsReady = true; then it creates an infinity loop. And that’s why, the browser will freeze.

Without apiIsReady set to true, you are creating loop that adds new value to array with each iteration of that same array.

You could check if array contains that value, if not, then push it

function load_all_waitting_inits()
{
  for(var opts of waitting_inits) // new values are being added with each iteration, preventing loop to end
  {
    init(opts); // parse value of waitting_inits array
  }
}

function init(opts) {
    loadPlayer();
    if (apiIsReady) { // always false
      addVideo(opts.video, opts.playerVars || {});
    }
    else
    {
      waitting_inits.push(opts) // here you are adding values infinitely
    }
}

This resolved, fixed the issue.

Check if array includes object.
https://jsfiddle.net/5umd9zfg/54/

function init(opts) {
    loadPlayer();
    if (apiIsReady) {
      addVideo(opts.video, opts.playerVars || {});
    }
    else if(!waitting_inits.includes(opts)) // if array doesn't include opts then push
    {
      waitting_inits.push(opts)
    }
}