AB Tasty — EmotionsAI
The problem
A major account client was complaining about the EmotionsAI tag’s latency on their production sites. On load, its initialization code blocked for more than 120 ms — that much time during which the client’s page stayed frozen.
The constraint
The EmotionsAI score had to stay strictly identical before and after: the smallest difference would have thrown off the calculations that depend on it. The code was old, and had to keep running on the old browsers it supported. I was alone on it.
The method
First I had to reproduce the problem: DevTools under simulated 3G conditions, then cross-checked on an external monitoring tool. The time was being lost on a long list of elements the tag walked through in full, when most cases didn’t even apply.
Two changes: narrow the list down to what can actually apply, and replace the linear scan with an O(log n) search — without breaking anything on the old browsers. The optimized tag shipped to production.
The result
−56%
Tag blocking time cut from 120 ms to 53 ms.
- JavaScript
- Python
- Jupyter
- BigQuery
- SQL
- Django
- MySQL