JavaScript is a popular programming language mainly used to insert dynamic elements into a website.

What is JavaScript?

JavaScript is a programming language, mainly used to insert dynamic elements into web pages. Examples of dynamic elements include automations, animations, interactive elements, traffic counters, etc. Without JavaScript, websites would be static, relying only on HTML and CSS. JavaScript is usually embedded in the HTML code of a web page or it can function in a separate file that is linked in the <head> section of HTML:

Why am I being asked to add JavaScript code to my website?

Many times, if you use a tool to enhance your website, it will ask you to copy-paste a JS <script> into your dashboard, so that it is displayed in the <head> of the HTML. If you trust the provider of the tool, this should not be a problem. This is something that the specified service needs in order to be able to add a certain functionality to your website. If you use a web building platform, like Wix or Wordpress or others, and install an extension or a plugin, it will often automatically add the needed JavaScript to your website. In some cases, you may still need to manually copy-paste a code into the header.

JavaScript issues and solutions

If you install too many plugins/extensions on a website, they could insert a great deal of JavaScript codes into the header. There are examples where a web page references more than 60-70 external JavaScript files in the <head> section. Before loading any content, the web browser will try to download all of these resources, slowing down the page load time significantly. There are several solutions for this, one of them being described in the dynamic rendering glossary entry.