Is there a way to load asynchronous html content?

0

I'm doing a web application, in cocreto I do a 5 step wizard but too many fields, but the file has already spread a lot and it takes a long time to load, the .js are already asynchronous, but the html is making it late in loading a lot. Is there a way to load steps 2 to 5 asynchronously, to avoid this delay?

    
asked by Chriz CR 10.01.2018 в 00:22
source

2 answers

0

You can not load asynchronous HTML5, since javascript works for it.

What you can do is create HTML code from Javascript and enter it into the DOM asynchronously, when you need it.

Example:

window.addEventListener("load", () => {
 setTimeout(()=> {
 document.body.innerHTML = '<h1> Bienvenido </h1> <p>
 Como estás? </p>';
 }, 1e3 * 2);
});
    
answered by 10.01.2018 / 01:51
source
0

What kind of technology are you working with?

What you could try is to load the html code from the controller, activating it when necessary by setting a parameter.

I do not specify a code or technology, since you have not put in what you work with.

    
answered by 10.01.2018 в 00:40