Description
Version
1.5.11
Module (core, cmpapi, cli, stub, or testing)
core
Describe with reproduction steps – What is the expected behavior?
TCString.encode(model)
is very slow because most of its runtime is spent in stringifying and parsing the GVL JSON as part of a clone()
operation in the TCModel. The TCModel has gvl
and publisherRestrictions
members where the publisherRestrictions
itself has a gvl
member too. This results in the GVL being cloned twice as can be seen in this Performance overview:
As Google is increasingly focusing on the INP CoreWebVital metric it is almost impossible to score favorably because of the bad performance of the encode operation. Google recommends to make sure the JavaScript main thread is not kept occupied more than 50 ms for each task for improved user experience. The task in the screenshot took 120 ms of which approx. 75 ms were spent in two getJson() calls.
Is there any reason why the GVL is cloned twice and why it is implemented like:
return JSON.parse(JSON.stringify({
gvlSpecificationVersion: this.gvlSpecificationVersion,
vendorListVersion: this.vendorListVersion,
tcfPolicyVersion: this.tcfPolicyVersion,
lastUpdated: this.lastUpdated,
purposes: this.purposes,
specialPurposes: this.specialPurposes,
features: this.features,
specialFeatures: this.specialFeatures,
stacks: this.stacks,
dataCategories: this.dataCategories,
vendors: this.fullVendorList,
}));