Per T204606, [[ https://phabricator.wikimedia.org/T204606#5484240 | analysis ]] was done on a subset of the `Fatal error: entire web request took longer than 60 seconds` errors found in logstash.
Most (**but not all**) of these errors were found to correlate to pages with either high image counts (> 1000) or high heading counts (> 1000). Therefore, if we want these pages to not timeout anymore, we could try skipping the MobileFormatter altogether under these scenarios.
**Caveats**:
- [[ https://phabricator.wikimedia.org/T204606#5484240 | Each of the cases ]] I looked at had extremely high total element counts (> 50,000 total elements on the page). The suggested fix may remedy the majority of the timeout errors, however client side performance on mobile devices could still be pretty abysmal (e.g. slow/unuseable repaints, scroll freezing, etc). Therefore, it's probably not wise to spend a lot of time implementing this fix as it's really just a bandaid for the majority of cases.
=== Dev notes
- Using [[ https://www.php.net/manual/en/function.preg-match-all.php | `preg_match_all` ]] to get the counts might work well here
=== Acceptance Criteria
[] When a page has > 1000 images or > 1000 headings, don't run the MobileFormatter. Be conservative. Check these numbers with Nick- make as high as possible to start with.
[] The number of images/headings should be configurable.