P.S. Just as a note... you wouldn't be doing much of anything DDoS prevention-related in javascript. Javascript loads in the browser, meaning that by the time it runs, the request has already hit the server, been okayed by said server, and the server has responded by loading in assets...