Microsoft had this back in IE 5.5. They were called "behaviors" and you could basically bundle HTML, CSS and JS into one file with a .htc file extension and then use it as a new tag in your document.
http://msdn.microsoft.com/en-us/library/ff626304(v=vs.85).as...