How JavaScript Works, in Very Broad Terms
Posted: Sun Jan 26, 2025 9:04 am
Without getting into unnecessary technical aspects, it can be useful to see in very general terms how JavaScript works, in order to better contextualize the problems and solutions that I will present to you later.
Let's start from the beginning: a user (or a bot, for example Googlebot itself) visits a web page.
The first thing that happens is that the browser forwards a request to the server to get:
The source code of the page
via subsequent requests, all external resources (stylesheets, JavaScript files, other purchase shareholder database resources) indicated in the source.
The source code is also called basic HTML because it is a document that contains all the basic contents of the page, as well as the instructions for downloading and running the JavaScript resources.
As the browser parses the source code and combines it with the CSS to “paint” the page on the screen, JavaScript resources are requested from the server and downloaded, then executed automatically or upon clicks, scrolls, or other user interactions .
In both cases, what the JavaScript language does is essentially inject new HTML code into the page or delete a part of it , or modify the existing one , in order to generate the appearance, disappearance or modification of elements. The result is a more dynamic and interactive web page.
But that's not all: JavaScript can also be used to postpone the loading of elements that are not immediately necessary , thus improving the performance of the page (this type of loading is called asynchronous loading or lazy loading ).
Let's start from the beginning: a user (or a bot, for example Googlebot itself) visits a web page.
The first thing that happens is that the browser forwards a request to the server to get:
The source code of the page
via subsequent requests, all external resources (stylesheets, JavaScript files, other purchase shareholder database resources) indicated in the source.
The source code is also called basic HTML because it is a document that contains all the basic contents of the page, as well as the instructions for downloading and running the JavaScript resources.
As the browser parses the source code and combines it with the CSS to “paint” the page on the screen, JavaScript resources are requested from the server and downloaded, then executed automatically or upon clicks, scrolls, or other user interactions .
In both cases, what the JavaScript language does is essentially inject new HTML code into the page or delete a part of it , or modify the existing one , in order to generate the appearance, disappearance or modification of elements. The result is a more dynamic and interactive web page.
But that's not all: JavaScript can also be used to postpone the loading of elements that are not immediately necessary , thus improving the performance of the page (this type of loading is called asynchronous loading or lazy loading ).