This code seems to do the trick. It uses the safeAttrs array to update the list of attributes you want to simplify. You can pass .removeAttr() list of attributes, separated by spaces, for deletion, so you don't have to loop through the attribute names one by one.
Finally, different browsers can handle attributes differently (for example, Chrome stores all attributes in lower case, so "dataFld" is stored as "datafld"), so it's best to normalize them with .toLowerCase()
var safeAttrs = ["datasrc","implementation","datafld","dataformatas","nofocusrect","datetime","cite"]; $('html *').each(function() { var attrs = $.map(this.attributes,function(attr) { if($.inArray(attr.nodeName.toLowerCase(),safeAttrs) < 0) { return attr.nodeName; } else { return null; } }); $(this).removeAttr(attrs.join(' ')); });
jsFiddle DEMO . Use Chrome or Firebug to verify the items received to verify that the attributes have been removed.
source share