[{"data":1,"prerenderedAt":418},["ShallowReactive",2],{"rule-duplicate-external-script":3},{"id":4,"title":5,"body":6,"breadcrumb":381,"coderail":388,"dateModified":407,"datePublished":407,"description":408,"extension":409,"meta":410,"navigation":411,"next":407,"path":412,"prev":407,"schemaType":413,"seo":414,"stem":415,"wide":416,"__hash__":417},"docs\u002Frules\u002Fduplicate-external-script.md","Duplicate external script loaded",{"type":7,"value":8,"toc":373},"minimark",[9,16,54,59,74,78,81,85,247,251,279,283,341,345,369],[10,11,12],"p",{},[13,14,15],"strong",{},"Summary",[17,18,19,30,36,42,48],"ul",{},[20,21,22,25,26],"li",{},[13,23,24],{},"rule_id"," — ",[27,28,29],"code",{},"duplicate-external-script",[20,31,32,35],{},[13,33,34],{},"purpose"," — Detect the same external script URL loaded by two or more Custom HTML tags",[20,37,38,41],{},[13,39,40],{},"effect"," — Redundant network requests and race conditions when two tags initialize the same library",[20,43,44,47],{},[13,45,46],{},"layer"," — container",[20,49,50,53],{},[13,51,52],{},"reversibility"," — non-destructive",[55,56,58],"h2",{"id":57},"what-fires-this","What fires this",[10,60,61,62,65,66,69,70,73],{},"The rule reads ",[27,63,64],{},"codeAnalysis.externalScriptUrls"," from each active Custom HTML tag. Paused tags are excluded. URLs are normalized by stripping the protocol (",[27,67,68],{},"https:\u002F\u002F"," or ",[27,71,72],{},"http:\u002F\u002F",") and any trailing slash. When the same normalized URL appears in two or more tags, the rule emits one finding per duplicate URL. A container with three distinct duplicated URLs produces three separate findings.",[55,75,77],{"id":76},"why-it-matters","Why it matters",[10,79,80],{},"Each tag that loads the same script URL issues an independent network request. For uncached resources, those requests block or delay dependent code. Race conditions are the sharper risk: when two tags load the same library simultaneously, the second initialization may corrupt shared state, reset configuration, or cause the library to report inflated counts. This pattern appears most often with jQuery, vendor analytics SDKs, and consent management libraries loaded once by a base template and again by a vendor snippet.",[55,82,84],{"id":83},"example","Before \u002F after",[86,87,88,185],"compare",{},[89,90,92,95,98,139,142],"compare-col",{"label":91},"Before — flagged",[10,93,94],{},"Two separate Custom HTML tags both load the same script URL.",[10,96,97],{},"Tag A — \"Google Maps Loader\":",[99,100,105],"pre",{"className":101,"code":102,"language":103,"meta":104,"style":104},"language-html shiki shiki-themes github-light github-dark","\u003Cscript src=\"https:\u002F\u002Fmaps.googleapis.com\u002Fmaps\u002Fapi\u002Fjs?key=ABC\">\u003C\u002Fscript>\n","html","",[27,106,107],{"__ignoreMap":104},[108,109,112,116,120,124,127,131,134,136],"span",{"class":110,"line":111},"line",1,[108,113,115],{"class":114},"sVt8B","\u003C",[108,117,119],{"class":118},"s9eBZ","script",[108,121,123],{"class":122},"sScJk"," src",[108,125,126],{"class":114},"=",[108,128,130],{"class":129},"sZZnC","\"https:\u002F\u002Fmaps.googleapis.com\u002Fmaps\u002Fapi\u002Fjs?key=ABC\"",[108,132,133],{"class":114},">\u003C\u002F",[108,135,119],{"class":118},[108,137,138],{"class":114},">\n",[10,140,141],{},"Tag B — \"Maps Widget Init\":",[99,143,145],{"className":101,"code":144,"language":103,"meta":104,"style":104},"\u003Cscript src=\"https:\u002F\u002Fmaps.googleapis.com\u002Fmaps\u002Fapi\u002Fjs?key=ABC\">\u003C\u002Fscript>\n\u003Cscript>initMap()\u003C\u002Fscript>\n",[27,146,147,165],{"__ignoreMap":104},[108,148,149,151,153,155,157,159,161,163],{"class":110,"line":111},[108,150,115],{"class":114},[108,152,119],{"class":118},[108,154,123],{"class":122},[108,156,126],{"class":114},[108,158,130],{"class":129},[108,160,133],{"class":114},[108,162,119],{"class":118},[108,164,138],{"class":114},[108,166,168,170,172,175,178,181,183],{"class":110,"line":167},2,[108,169,115],{"class":114},[108,171,119],{"class":118},[108,173,174],{"class":114},">",[108,176,177],{"class":122},"initMap",[108,179,180],{"class":114},"()\u003C\u002F",[108,182,119],{"class":118},[108,184,138],{"class":114},[89,186,188,195,198,220,223,244],{"label":187},"After — fixed",[10,189,190,191,194],{},"One dedicated loader tag loads the script once. The init tag declares it as a setup dependency via Tag Sequencing and removes the duplicate ",[27,192,193],{},"\u003Cscript>"," call.",[10,196,197],{},"Tag A — \"Google Maps Loader\" (unchanged):",[99,199,200],{"className":101,"code":102,"language":103,"meta":104,"style":104},[27,201,202],{"__ignoreMap":104},[108,203,204,206,208,210,212,214,216,218],{"class":110,"line":111},[108,205,115],{"class":114},[108,207,119],{"class":118},[108,209,123],{"class":122},[108,211,126],{"class":114},[108,213,130],{"class":129},[108,215,133],{"class":114},[108,217,119],{"class":118},[108,219,138],{"class":114},[10,221,222],{},"Tag B — \"Maps Widget Init\" (deduplicated):",[99,224,226],{"className":101,"code":225,"language":103,"meta":104,"style":104},"\u003Cscript>initMap()\u003C\u002Fscript>\n",[27,227,228],{"__ignoreMap":104},[108,229,230,232,234,236,238,240,242],{"class":110,"line":111},[108,231,115],{"class":114},[108,233,119],{"class":118},[108,235,174],{"class":114},[108,237,177],{"class":122},[108,239,180],{"class":114},[108,241,119],{"class":118},[108,243,138],{"class":114},[10,245,246],{},"Tag B uses Tag Sequencing → Setup Tag: \"Google Maps Loader\".",[55,248,250],{"id":249},"remediation","Remediation",[252,253,254,257,260,266,269,276],"ol",{},[20,255,256],{},"Open the finding detail and note all tags loading the duplicated URL.",[20,258,259],{},"Designate one of those tags as the sole loader. Remove any other logic from it — load only the script.",[20,261,262,263,194],{},"In all remaining tags, delete the duplicate ",[27,264,265],{},"\u003Cscript src=\"…\">",[20,267,268],{},"Use GTM (Google Tag Manager) Tag Sequencing to make each dependent tag wait for the loader tag to fire successfully.",[20,270,271,272,275],{},"Add a guard in the loader tag to prevent double-loading if the tag fires more than once: ",[27,273,274],{},"if (!window.libraryNamespace) { \u002F* load script *\u002F }",".",[20,277,278],{},"Verify in Preview mode that the script loads exactly once and all dependent tags function correctly.",[55,280,282],{"id":281},"metadata","Metadata",[284,285,288,289,294,288,298,302,288,305,309,288,312,315,288,318,322,288,325,329,288,335,338],"dl",{"className":286},[287],"spec-list","\n  ",[290,291,293],"dt",{"id":292},"severity","Severity",[295,296,297],"dd",{},"medium",[290,299,301],{"id":300},"tier","Tier",[295,303,304],{},"optimization",[290,306,308],{"id":307},"category","Category",[295,310,311],{},"performance",[290,313,314],{"id":46},"Layer",[295,316,317],{},"container",[290,319,321],{"id":320},"version","Version",[295,323,324],{},"1",[290,326,328],{"id":327},"effort","Effort",[295,330,331,334],{},[27,332,333],{},"2hr"," (about 2 hours)",[290,336,337],{"id":52},"Reversibility",[295,339,340],{},"non-destructive",[55,342,344],{"id":343},"see-also","See also",[17,346,347,355,362],{},[20,348,349,354],{},[350,351,353],"a",{"href":352},"\u002Fcategories\u002Fperformance\u002F","Performance rules"," — other rules in this category",[20,356,357,361],{},[350,358,360],{"href":359},"\u002Fhealth-score\u002F","Health score"," — how this rule contributes to the score",[20,363,364,368],{},[350,365,367],{"href":366},"\u002Frules\u002F","Rules catalog"," — browse all rules",[370,371,372],"style",{},"html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":104,"searchDepth":167,"depth":167,"links":374},[375,376,377,378,379,380],{"id":57,"depth":167,"text":58},{"id":76,"depth":167,"text":77},{"id":83,"depth":167,"text":84},{"id":249,"depth":167,"text":250},{"id":281,"depth":167,"text":282},{"id":343,"depth":167,"text":344},[382,385,387],{"label":383,"href":384},"API Reference","\u002F",{"label":386,"href":366},"Rules",{"label":29},{"cards":389,"onpage":401},[390],{"title":391,"tabs":392},"Evaluate",[393,397],{"label":394,"language":395,"code":396},"cURL","bash","curl https:\u002F\u002Fdeveloper.tagmanifest.com\u002Fv1\u002Fevaluate-rule \\\n  -H \"Authorization: Bearer $TM_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"rule_id\":\"duplicate-external-script\",\"url\":\"https:\u002F\u002Fexample.com\"}'\n",{"label":398,"language":399,"code":400},"MCP","text","User: Run duplicate-external-script on https:\u002F\u002Fexample.com\n\n# Tool call\n{\n  \"tool\": \"evaluate_rule\",\n  \"arguments\": {\n    \"rule_id\": \"duplicate-external-script\",\n    \"url\": \"https:\u002F\u002Fexample.com\"\n  }\n}\n",[402,403,404,405,406],{"id":57,"label":58},{"id":76,"label":77},{"id":83,"label":84},{"id":249,"label":250},{"id":281,"label":282},null,"The same external script is loaded by multiple tags, creating redundant network requests and potential race conditions.","md",{},true,"\u002Frules\u002Fduplicate-external-script","TechArticle",{"title":5,"description":408},"rules\u002Fduplicate-external-script",false,"US7W6ASfzdczsjXSOXAYto_2sP4w3t0du7NHvQcnbCA",1796069484167]