Skip to content

Commit

Permalink
perf: preload _locales/en/messages.json so we don't have to wait as…
Browse files Browse the repository at this point in the history
… long for our JS to dynamically load it (#26556)

We always load the English version of `messages.json`. This PR makes use
of link `rel=preload` so that the browser will get the file ready for
use immediately -- well before our JavaScript file that will eventually
need it asks for it. This reduces the amount of waiting due to Network
Waterfall (even if the network is the local file system).
  • Loading branch information
davidmurdoch authored Sep 18, 2024
1 parent 107f8da commit f06b7a0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<% } else { %>
<title>MetaMask</title>
<% } %>
<link rel="preload" href="/_locales/en/messages.json" as="fetch" crossorigin="anonymous" />
<link rel="stylesheet" href="../ui/css/index.scss">
</head>
<body>
Expand Down
1 change: 1 addition & 0 deletions app/notification.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
margin-top: 1rem;
}
</style>
<link rel="preload" href="/_locales/en/messages.json" as="fetch" crossorigin="anonymous" />
<link rel="stylesheet" href="../ui/css/index.scss" />
</head>
<body class="notification">
Expand Down
1 change: 1 addition & 0 deletions app/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>MetaMask</title>
<link rel="preload" href="/_locales/en/messages.json" as="fetch" crossorigin="anonymous" />
<link rel="stylesheet" href="../ui/css/index.scss" />
</head>
<body style="width:357px; height:600px;">
Expand Down

0 comments on commit f06b7a0

Please sign in to comment.