Webflow custom code map: where each of the 5 code boxes lands, and 6 reasons a snippet doesn't run

Article

Webflow gives you five places to paste custom code. The one you pick decides which pages get the snippet, where it lands in the published HTML, and whether you can see it working in the Designer.

Here's the map. Every rule is from the Webflow Help Center, and I checked the order in the published HTML of two live Webflow sites:

1) Site settings › Custom code › Head code: before </head> on every page. <link>, <meta> and <style> tags always go here.

2) Page settings › Custom code › Inside <head> tag: the same spot, on that page only, after the site-wide head code.

3) Code Embed: inline, exactly where you drop it on the canvas or inside a Rich Text element, and only on pages that include it. It can use CMS fields, and you can turn it into a component to reuse it.

4) Site settings › Custom code › Footer code: before </body> on every page. In the published HTML it sits right after Webflow's own jquery-3.5.1 and webflow.js script tags, so with the default publishing settings a plugin there doesn't need its own jQuery.

5) Page settings › Custom code › Before </body> tag: the same spot, on that page only, after the site-wide footer code.

Each of the four settings boxes and each Code Embed holds up to 50,000 characters. For longer code, host the file elsewhere and reference it, minify it, or split it across embeds.

When a snippet doesn't run, I go through these before rewriting anything:

1) Works in Preview, not on the live site: custom code runs in Preview, but it only goes live when you publish.

2) A placeholder on the canvas: <script> embeds show a placeholder in the Designer, and custom code doesn't run in expand canvas view. <iframe> and <style> embeds do preview on the canvas.

3) The layout broke after pasting: the snippet brought its own <html>, <head> or <body> tags, or a tag isn't closed. Prettify in the code editor flags syntax errors.

4) A jQuery plugin acts up: the site already loads jQuery 3.5.1, and importing another version can conflict.

5) It stopped after turning on Asynchronously load JavaScript (Site settings › Publishing › Advanced publishing options): add defer to external scripts, and wrap inline code in window.addEventListener('load', ...).

6) Analytics counts your Preview visits: custom code also runs in Preview and Comment modes. Wrap it in <!-- EXCLUDE FROM PREVIEW: START --> and <!-- EXCLUDE FROM PREVIEW: END -->.

The Help Center also suggests keeping a list of every script on a site: what it is, why it was added and who owns it. Do you keep one for your client sites, or does it only come together during an audit?

1