Join GitHub today
Refactor bindRemoveButtons for improved performance #1144
There are known issues in Magento managing options with thousands of attributes.
In my my profiling I found that bindRemoveButtons is the culprit in terms of the inefficiency. Each time an option is appended to the DOM bindRemoveButtons checks every single delete button on the page. You can imagine how that could add up when working with attributes with thousands of options.
This PR refactors the options template implements bindRemoveButton (rather than bindRemoveButtons) so that when an option is appended to the DOM only the delete button for that option gets bound.
Based on my testing going from bindRemoveButtons() to bindRemoveButton() had a larger impact on performance, but this helped as well. That being said managing attributes with thousands of attributes has slowed down in Magento 2 when compared to Magento 1.
I have used the SQL scripts below to set up a dropdown attribute with 3,500 options in Magento 2, and Magento 184.108.40.206. Both installs are running on the same VM.
Testing in Chome 41.
I would say this PR is definitely improvement. One change that could be considered which would be of larger scope would be to add pagination.