jquery/jquery-ui — pull request #1183 by amakhrov (2014-01-23 19:43:53+00:00)
Title: ui.widget: don't trigger 'remove' event for non-widget elements

An updated version of the [previous](https://github.com/jquery/jquery-ui/pull/1182) pull request

ui.widget overrides the `$.cleanData` method to also call `.triggerHandler( "remove" )` method. According to Chrome's profiler, `triggerHandler` is a relatively slow method.

When element is being removed with `$(elem).remove()`, `$.cleanData` is called for each descendant element - and there can be thousands of those elements!

This is an attempt to only execute `triggerHandler( "remove" )` for elements that are jQueryUI Widgets and skip that for all other elements.

[Benchmark](http://jsperf.com/jquery-ui-remove-elements) - pure jQuery vs jQueryUI vs fixed jQueryUI