MIME Test - Hybrid Comments with JavaScript

Back to the MIME Type Tests.

Traditionally, JavaScript functions are commented out with SGML comments to let the parser know they are not to be parsed. To hide data from an XML parser, the data should be enclosed in a CDATA section. As older browsers do not understand CDATA, some people advise that the CDATA section is hidden from the browser using SGML comments, followed by JavaScript comments to save the script from itself.

The following JavaScript function has been specified in the head of this document.

function hybrid()
    alert('Hybrid approach');

When served as application/xhtml+xml, the function is ignored. When served as text/html, the function is executed. Test Hybrid Comments.