As opposed to .htaccess which can only password protect directories, javascripts can be used to protect individual files. The tradeoff? While less so than in the past, security may be diminished.