dimanche 1 avril 2018

Why does Chrome send ajax late for a simple page?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
        const jsonPromise = fetch("https://www.google.com");
        jsonPromise.then(() => alert("done"));
    </script>
</head>

<body>
</body>
</html>

This is my HTML. The graph shows the HTML download finished early but the ajax is sent at 181ms.

I believe Chrome doesn't need 180ms to parse the simple HTML. What is it doing in the interim? Can Chrome send the request as soon as possible?

In my real application, I request JSON from my server. The JSON is the critical data for rendering the page, otherwise the page is blank. That's why I want the browser to send the request as early as possible.

enter image description here enter image description here The same happens for Firefox




Aucun commentaire:

Enregistrer un commentaire