Quick repo to demonstrate how one might include just the TCString decoder in their project.
This provides a lightweight version of just the IAB's decoder:
https://github.com/InteractiveAdvertisingBureau/iabtcf-es/tree/master/modules/core#installation
This specific repo leverages npm
with webpack
to bundle just the required libraries to decode an IAB TCF v2 string.
The output will be a lightweight minified JS file that you can plug in locally, or use however you like.
You can choose to bundle the TCF library yourself if you like if you already leverage webpack or an equivalent today.
- Node.js (tested with v18.11.0)
- NPM (tested with 8.19.2)
- Clone this repo.
git clone https://github.com/foreza/iab-tcf-decoder-built
- Install node packages (webpack + iab tcf core).
npm install
- Run webpack.
npx webpack --mode production
Output: this produces TCStringDecoder.js
in the /dist
folder.
Here is an example.
- Include
TCStringDecoder.js
as a standalone script. - Use
TCString.decode(<your tcf iab string>)
- it'll output anTCModel
object. - Parse the
TCModel
for whatever you need.