Skip to content

Preload fetched data into index.html

Steven Fuchs requested to merge stwf/pleroma:preload-data-2 into develop

This MR addresses some performance issues by inserting data into script tags into the served index.html file. This will allow FE developers to bypass several data fetches. The code has been tested with an FE mockup and works, decreasing page load time noticably. In addition the encoding has been tested against as many problematic posts as I can think of ("", "%>", "\>", etc) and seems to be impervious.

The data will be represented by a map, with the keys being the url the data resides at. The tag looks like this.

<script id="initial-results" type="application/json">
# JSON of initial data map
</script>

It currently supports the following url's.

%{
  "/api/v1/accounts": %{},
  "/api/v1/instance": %{},
  "/api/v1/timelines/public": [],
  "/instance/panel.html": "",
  "/nodeinfo/2.0": %{}
}

Merge request reports