Yea - SU tries to clean up some times. If you for instance erase all the entities in a ComponentDefinition that definition will disappear. (Though I'm not exactly sure when SU does that.)
Another tip which I might not have mentioned in that article, I find using a javascript framework (like jQuery) takes the pain out of the cross-compatibility JS issues.