Why not just replace this whole block with something like `attrMap[attr[len]] = $(features[len]).filter('script')`? <- Not working code, just a rough idea.