0

I want to copyright my JS library, or more "showing that it's ME who did it", like here.

The expected result would be that if you write

<script src="myLib.js" ></script>

It's a completely working library.

And if you write

<img src="myLib.js" />

It will show my logo.

I would like an explanation of the way to do it step by step.

P.S: The answers of Is this a web page or an image? are explaining how it can work; but what I want is to know the procedure to do for any image with any file.

Community
  • 1
  • 1
Alexandre Khoury
  • 3,896
  • 5
  • 37
  • 58
  • Don't do this, as it will make the js file a lot bigger than needed. I've never tried embedding a JS file as an image, so it's not as if people will realise this works anyway! – Rich Bradshaw Jul 21 '12 at 11:10

1 Answers1

1

It's not possible with javascript because with this trick your file has to start with 0xFF 0xD8 0xFF 0xE0... and there is no way to make javascript ignore that. It will just immediately give up because of a syntax error.

Any other binary format likely has the same problem as well. They'd need to start with 0x2F 0x2A (/*) to even consider it.

It's different with html because html is not afraid of seeing 0xFF 0xD8 0xFF 0xE0...

Esailija
  • 138,174
  • 23
  • 272
  • 326