TMS Best Practices: Deduplicate scripts and events

This is a “low hanging fruit” best practice, but one that most companies could gain from: consolidate tags from the same vendor. Especially if they load an external JavaScript file. For instance, if I’m deploying both an Adwords GTAG and a Doubleclick GTAG, I might paste them both as custom code:

This means that “” file loads twice. It’s a 40 KB file, with no benefit for loading multiple times.

This code accomplishes the same thing, minus 40 KB of dead weight:

I’ve seen folks shave 200KB off their site by merely getting rid of extra gtag/js files. You can take it a step further and consolidate events, too- I don’t need to fire a conversion event twice, I can just add multiple destinations to my send_to variable:

This tip isn’t specific to gtag, though that is one of the tags that I see duplicated the most. Anytime you are deploying two tags from the same vendor on a page, odds are there is some part of that code that doesn’t need to be repeated.

Leave a Reply

Your email address will not be published. Required fields are marked *