Generally, when dealing with this situation, everyone uses ajax, first outputs the html to the client, and then uses ajax to retrieve and load resources that are time-consuming. The trouble with using ajax is that it increases the number of requests, and requires writing additional js code and request interfaces called by js.
For this situation, there is another way to deal with this situation, which is to let the response be encoded in blocks for transmission. The response is encoded in blocks. You can first transmit a part of the HTML code that does not need to be processed to the client, and then transmit the other HTML code after other time-consuming codes have been executed.
Chunked encoding (chunked encoding)
Chunked encoding is an encoding format that is only supported by http1.1 (of course, no browser currently does not support 1.1). The difference between chunked encoding and general response is as follows: