Expand my Community achievements bar.

Photoshop UXP layer iteration


Level 1
I've been seeing very slow performance in an addon I am currently developing.  I have tracked down the major slowdown to needing to iterate layers a lot.
While testing, I added a simple forEach iteration for layers just to see if the iteration or the code action for layers was the problem.   And the below line runs at almost exactly the same speed.
Is there a faster way to check all the layers under a layer in UXP?
Sample code:
.layers.forEach((elem)=> {});
The above line takes 250ms to run one time, and I am doing this for multiple layers.  So I end up with a routine I was expecting to take a second maximum taking 20 plus seconds, which is rather painful to do on document select/open/close.

1 Reply



Hi there!


Photoshop UXP discussions should be posted in our Creative Cloud developer forum. These forums aren't connected so I can't directly transfer the post, unfortunately. 


How did you find and choose this forum for posting your question? Just asking so I can do better traffic direction...


That said, @jarda says the following:

DOM takes always live objects from PS. There is no caching even if document did not change at all.


I have 6 versions of "delete empty layers" script for UXP and last version is 56× faster than first one which is using mostly DOM but still used optimization that 3rd party is not using yet.

Please ask any follow up questions in the other forum...