DEV Community

Discussion on: How we decreased load time by 40% by removing just 1 file

Collapse
 
joshcheek profile image
Josh Cheek

Love it!

I found something similar: We were shipping fkn megs of data in our SSR'd JSON payloads. Curled the endpoint, used sed to strip it down to the JSON, a small JS script to unminify it, and then started exploring with jq. After a little bit, realized that 90% of the payload was duplicated at another location in the payload. Turns out we were using some redux and so some toplevel component received the data, hung onto it, and passed it to one of its children. In memory, this isn't an issue b/c they both point to the same spot in memory. But JSON doesn't have a feature for referencing values from other spots in the structure (interesting note: YAML does). So, when we serialized the entire state, that memory got rendered twice. Turns out it wasn't needed by the parent, so we removed it and the initial payload was cut by almost half.

Collapse
 
mladenstojanovic profile image
Mladen Stojanovic

Yikes, what a weird problem :)

But that feeling when you delete it and it starts working so fast... Priceless :D