Dynamically built interface
What you’re seeing are sites whose interfaces are built entirely or partially via Javascript, i.e., code that runs in your browser.
Usually you get a very basic HTML when you go to the page, plus a set of data, plus a few scripts.
Later, more data can be loaded over time in asynchronous requests using Ajax.
What good is
This type of technique escapes a little from the standards of the web, being generally adopted to improve the user experience, not making it wait for page after page loading.
This feels like using a conventional program instead of a web site.
Problems
On the other hand, developing such web applications is more laborious and more prone to errors.
Examples
Single page Applications (single-page applications), by their very nature, generally adopt this type of strategy.
This is the case, for example, of Gmail. It loads all the necessary code and structures as soon as you access it. Then, you can perform a series of tasks without transferring data from the server.
In Google apps in general, there is even partial support for working offline.
How this is done in practice
In general there are two strategies for dynamic generation of elements:
Creation of elements programmatically
Dog created instances of objects that represent the HTML tags and then they are added somewhere on the page.
This is done with the function createElement
of Javascript. Example:
//cria tag <p>
var minhaDiv = document.createElement("p");
//adiciona um texto
var conteudo = document.createTextNode("Olá!");
minhaDiv.appendChild(conteudo);
//adiciona tag na página
document.body.appendChild(minhaDiv);
Creation based on an HTML template
You can also inject a chunk of HTML code somewhere on the page.
This can be done using the attribute innerHTML
of an existing element in the page. Example:
//substitui todo o conteúdo da página por "Olá"
document.body.innerHTML = "Olá";
There is some difference in performance between the two forms, but in the end the result is the same.
I could understand perfectly, thank you very much Voce who explained that they put the data in js to then load with SPA aid as the friend from above said.
– Vinicius Eduardo
Pity that SPA, uses browser features, and if misapplied, will make it use more ram memory, and make the system become slower =\
– Rod
@Rod There are other problems besides this. The staff is abusing in their use.
– Maniero
@bigown yes, is one of them...are several, there are positive and negative points, I believe that SPA is not a good for corporate applications
– Rod