Well, the question has changed. Blah. Here is the new answer:
You can improve performance a bit by building a branch before adding it to the DOM tree (the browser will not try to redo anything during construction). And a little in the way of service efficiency, reducing the number of unnecessary variables:
var d = document;
var docBody = d.getElementsByTagName("body")[0];
var sasDom = d.createElement('span');
sasDom.setAttribute("id", "sasText");
var sasDomHider = d.createElement('span');
sasDomHider.setAttribute("id", "sasHider");
sasDomHider.appendChild(sasDom);
docBody.appendChild(sasDomHider);
Original answer:
You are trying to insert the same element twice in the same place ...
var newNode = d.createElement('span');
... , . , . :
docBody.appendChild(newNode);
. node , sasDomHider... ! , node .
, :
newNode = d.createElement('span');
newNode.setAttribute("id", "sasText");
sasDomHider.appendChild(newNode);
sasDom = newNode;