Reviving an old iPad Air 1 (iOS 12.5.8, 1GB RAM) as a wall dashboard using a custom lightweight HTML/JS WebSockets client
Hi everyone in the Home Assistant community,
Like many of you, I hit a hard wall when trying to use old tablets as dedicated wall panels. With modern versions of Home Assistant, the official frontend (Lovelace and its modern Lit/Polymer dependencies) has simply become too heavy for the old WebKit engine in iOS 12, leading to constant freezes and Out-Of-Memory (OOM) crashes/reboots.
Instead of throwing away my first-generation iPad Air, I decided to build from scratch an ultra-lightweight Single Page Application (SPA) using vanilla HTML5, CSS3, and JavaScript that communicates directly with Home Assistant via WebSockets.
What does this custom dashboard include?
- Mushroom-inspired UI: Clean cards, interactive chips, and a design tailored for fixed touchscreens.
- Media player & cameras: Local media server control and camera streams with built-in error handling.
- Weather, maps, and tasks: Integration with to-do lists, calendar events via WebSockets, and Leaflet maps for device trackers.
- Advanced memory management: Specifically engineered to prevent memory leaks in iOS 12.
How is it structured technically? (Key highlights)
1. Native WebSockets Connection without loading Lovelace
Instead of loading the entire Home Assistant graphical framework, the script opens a direct socket with the core and handles states reactively:
function connectWS() {
if (!HA_TOKEN || !HA_URL) return;
var wsProtocol = HA_URL.indexOf('https') === 0 ? 'wss:' : 'ws:';
var cleanHost = HA_URL.replace(/^https?:\/\//, '');
var wsUrl = wsProtocol + '//' + cleanHost + '/api/websocket';
ws = new WebSocket(wsUrl);
ws.onmessage = function (event) {
var data = JSON.parse(event.data);
if (data.type === 'auth_required') {
ws.send(JSON.stringify({ type: 'auth', access_token: HA_TOKEN }));
} else if (data.type === 'auth_ok') {
sendWS({ type: 'get_states' });
sendWS({ type: 'subscribe_events', event_type: 'state_changed' });
}
};
}
2. Preventing freezes from mass events (requestAnimationFrame)
Home Assistant can fire dozens of state_changed events simultaneously on startup or view changes. To prevent the iPad’s main thread from collapsing, UI updates are queued and processed in a single batch during the next screen refresh cycle using requestAnimationFrame:
var pendingEntityUpdates = {};
var rafScheduled = false;
function queueEntityUpdate(ent) {
pendingEntityUpdates[ent.entity_id] = ent;
if (!rafScheduled) {
rafScheduled = true;
requestAnimationFrame(function() {
rafScheduled = false;
var entitiesToUpdate = pendingEntityUpdates;
pendingEntityUpdates = {};
for (var id in entitiesToUpdate) {
if (entitiesToUpdate.hasOwnProperty(id)) {
updateEntityUI(entitiesToUpdate[id]);
}
}
});
}
}
3. Zero memory leaks on legacy WebKit
Older browsers on iOS easily leak memory if you continuously reload images or camera feeds. To fix this, strict buffer clearing and preloaders are implemented:
var imgPreloader = new Image();
imgPreloader.onload = function () {
for (var i = 0; i < ids.length; i++) {
var imgEl = document.getElementById(ids[i]);
if (imgEl) imgEl.src = url;
}
imgPreloader.onload = imgPreloader.onerror = null;
imgPreloader = null;
};
imgPreloader.onerror = function () {
imgPreloader.onload = imgPreloader.onerror = null;
};
imgPreloader.src = url;
Additionally, when switching tabs in the sidebar, images on inactive views are cleared (src = '') to instantly release the iPad GPU’s memory.
4. DOM Caching for CPU optimization
To avoid repetitive and expensive calls to document.getElementById(), a local caching dictionary is used:
var domCache = {};
function getCachedElement(id) {
if (!domCache[id]) {
domCache[id] = document.getElementById(id);
}
return domCache[id];
}
Conclusion
If you have an old iPad sitting in a drawer because it can no longer handle modern home automation apps or heavy web interfaces, building a lightweight SPA based on pure WebSockets is the best alternative to breathe new life into it as a wall control panel. It runs incredibly smooth!

