How to check if the document is empty or not before adding elements from the plugin?

I’m having a problem adding artboards from the plugin when there are elements already in the document/pasteboard.
For example if there is a text I can’t add an artboard from the plugin.

const addArtboard = () => {
  let btns = document.querySelectorAll("button");

  const getValues = (event) => {
    let activeBtn = event.currentTarget;
    let name = activeBtn.getAttribute("data-name");
    let fname = activeBtn.getAttribute("data-fname");
    let width = activeBtn.getAttribute("data-width");
    let height = activeBtn.getAttribute("data-height");

    editDocument({ editLabel: "add artboard" }, (selection, documentRoot) => {
      let newArtboard = new Artboard();
      newArtboard.height = JSON.parse(height);
      newArtboard.width = JSON.parse(width);
      newArtboard.fill = new Color("#ffffff");
      newArtboard.name = name;
      newArtboard.fname = fname;

      documentRoot.addChild(newArtboard);
    });
  };

  for (let i = 0; i < btns.length; i++) {
    btns[i].addEventListener("click", getValues);
  }
};

I’m so happy I found the solution and it was so easy.
For anyone who would have the same problem:

I just had to add the index of 0 here:

documentRoot.addChild(newArtboard, 0);