This question Photoshop Script to create text in a bitmap image in Photoshop already has answer how to create text layer in photoshop, but as result in history tab you can see 8-10 history state changes. Is there a way to do the same job, but while changing history only once?
Obviously problem is that mentioned answer first adds a layer to document and then edits it 8-10 times and solution would be to create a layer and edit it's properties and then after it's ready add it to document.
I have searched in Photoshop CC 2014 Javascript Scripting Reference and it lists only 3 methods for ArtLayers methods: add(), getByName() and removeAll().
Function add() creates new layers, adds it and then returns it. So according to Javascript Scripting Reference I don't see how it would be possible to first create a layer and then add it.
I am still asking because possibly I have missed something or there is an official way to do it, but has not made it into the official docs for some reason.