What is the main purpose of Javascript?
To make your website dynamic. You can use scripts that run on the clients machine (smartphone, laptop, etc) and therefore you reduce the connections and traffic on your website. JavaScript can also be used offline.