If you just want to initially hide elements, you could clear the graphical representation of it:
var elementIds = [ "1", "4", "6" ];
// get all elements with the above ids
var elementsToHide = elementRegistry.filter(function(element) {
return elementIds.indexOf(element.id) >= 0;
});
// get the graphical representation of these elements and hide clear it
forEach(elementsToHide, function(element) {
var gfx = elementRegistry.getGraphics(element);
gfx.clear();
});
Please note that the element is invisible but still exists, and nothing is changed in the XML.
Does this fit your use case?