You can use URI to embed images too, not sure how this is done though, why not just use URI?
This is different: it's a single file which can be parsed as either a HTML page or a JPEG. Hence, when a program expects a HTML page (like a browser loading a Web page), it will be parsed and displayed as a HTML page. When a program expects a JPEG file (like a browser loading the "src" of an "img" element) it will be parsed and displayed as a JPEG.
The trick is to use each format's comment syntax to hide the other format. Not sure if the HTTP headers need to be set differently for each request or not.
$ curl -I http://lcamtuf.coredump.cx/squirrel/
HTTP/1.1 200 OK
Date: Thu, 11 Aug 2016 05:18:00 GMT
Server: Apache
Last-Modified: Mon, 19 Sep 2011 23:31:49 GMT
Accept-Ranges: bytes
Content-Length: 135938
Content-Type: text/htmlI guess browsers only forbid ignoring Content-Type for stuff like JS, then. For JPEG it's probably not a security concern.