There is only one way to protect your Javascript, or HTML code, or images, or video, or anything else . . . . . .
Don't publish it on the Internet.
If I can see your page and I'm determined enough, I can steal it.
Look at it this way.
You learned most of everything you know from view source and by example, correct? Be honest. You know you did, we all do, it's the same thing as reading examples from a textbook.
Two things can be extracted from this.
1. Nothing you code up is really new and is built on the knowledge of those that came before you. You owe it to the community you learned from to share what you know and pay it forward. An additional benefit is when others see your code, and you are open to it, they can point out security flaws or more efficient ways of structuring it. This is the foundation of "open source" - not the Internet mentality of "free, free, free," but the idea, "let's collaborate and make the best it can be."
2. Unless you're some genius above and beyond the best coders out there, what you wish to protect can be found in thousands of other places and is not really worth protecting.
Don't take that as a devaluation of your achievements, it's not.
It's just true.
Ive been doing this for 16 years, Perl, PHP, ASP, JS, VBscript, Flash, all of it - and this is my position on protecting code.