Hello Kostadin,
Actually, in this instance, using a ('#') isn't the problem. Just using a simple in-line comment causes the popup edit template from loading:
Putting this at the top of the template will cause the script error. I also tried escaping the comment with no luck. Please try it yourself and see if you get the same results.
<script>
function someFunction(e) {
//some comment
}
</script>
Thanks,
Mike