doc is under window.. Copied a lot from js-experiment repo from Tasos