A collection of simple speedups
If you have a Web application there are likely countless ways you can speed it up, some with significant performance gains, and some adding up to significant gains if you apply enough of them.
Application startup time
Does your Web application load data from the backend asynchronously using JavaScript before a page can even be displayed, for example configuration or data for the initial screen?
Any initial data that is required can be loaded at the same time as the page's javascript bundle by the browser. Simply serve the data as JavaScript files which populate a variable:
<html>
<head>
<script src="/application.js"></script>
<script src="/config.js"></script>
...
In this example config.js is a file generated by the backend to contain the data in ready-to-execute JavaScript form:
window.Config = {
siteTheme: 'aqua',
websocketPort: 12345,
}
If you only start executing your application's code on `window.onload` then these values are guaranteed to be present because all scripts have loaded by then.
This also allows you to simplify your application code: you can remove the JavaScript code which was waiting on those initial asynchronous requests completely, and some loading spinner logic.