Quick answer
Does Webflow support custom code?
Yes. Webflow runs the HTML, CSS and JavaScript that you add in site settings, page settings or an embed element. It does not run server side code.
The short answer
Yes. Webflow runs the HTML, CSS and JavaScript that you add in Site settings, Page settings or a Code Embed element (up to 50,000 characters per field). You need a paid Site plan or a Core, Growth, Agency or Freelancer Workspace. Server side languages (e.g. PHP, Python) do not run.
Answered by Stefan Velikov, Webflow Premium Partner since 2022
The detail
- 1Code goes in three locations: the site wide head and footer, the page level head and before body, and within Code Embed elements.
- 2Each of those fields can hold up to 50,000 characters. Longer code can be hosted elsewhere and referenced.
- 3Only HTML, CSS and JavaScript will run. There is no server side language.
- 4You need a paid Site plan or a Core, Growth, Agency or Freelancer Workspace.
- 5Webflow doesn’t guarantee that it will be compatible with any custom code and their support team will not troubleshoot custom code.
- 6Custom code shows up in the preview and only becomes live when you publish.
Where the code goes
Site Settings has a Custom Code tab with a Head Code field and a Footer Code field. Anything you put in there will load on every page. Page Settings has its own two fields, one in the head and one before the closing body tag and that code will only load on that particular page. The Code Embed element can be placed anywhere in the design or within a rich text element and will execute wherever you place it.
What it cannot do
Custom code fields accept HTML, CSS and JavaScript. They do not accept server side languages (e.g. Perl, PHP, Python, Ruby). If you need server side work then Webflow Cloud will host your Next.js or Astro application on Webflow’s infrastructure or you can call an external service. Don’t paste in html, body or head tags as that will break the layout. Sites published from August 2020 onwards have jQuery 3.5.1 so loading a different version of jQuery may result in conflicts.
Keep it fast
Every script loads on every page it’s included on. Webflow’s recommendation is to use the smallest possible scope i.e. a Code Embed for a single spot, page settings for a single page, site settings for code that’s required on every page. A plain script tag will block the page whilst it’s downloading. Adding “async” allows scripts such as analytics to load independently when they’re ready. “defer” will run the script after the page has been parsed and keeps the scripts in order. Webflow’s site usage dashboard will flag any JavaScript and CSS bundles over 250KB and will suggest that you move page specific scripts to the page that uses them. Webflow also has a publishing setting called “Asynchronously load JavaScript” which can have an effect on scripts that are reliant on Webflow’s own JavaScript. That’s all covered in the Custom code in Webflow section.
Check whether you need code at all
Some jobs now have a native option. Modals are a built-in element which uses the browser’s dialog element and are available on all Site plans. Published modals will open and close without any Webflow JavaScript unless you’re animating them. There’s also a native spam protection option for forms. Always check the native option before you go and add a script that you then have to maintain.
Support
Webflow’s help articles are very clear on the fact that custom code is an advanced change which can in fact conflict with Webflow’s own functionality and that their support team in no way can assist you with the setup or troubleshooting of custom code. They will point you towards the Webflow community in that instance. If your site is taking payments via Webflow Ecommerce then any scripts you add are completely outside of Webflow’s control and any PCI obligations that arise as a result are yours.
Related questions
Do I need a paid plan in order to add custom code?
Yes, you need a Core, Growth, Agency or Freelancer Workspace or a site with an active Site plan. The Webflow GA integration will work with a free plan, but any additional custom code will not.
Why does my script do nothing in the Designer?
Scripts within a Code Embed only appear as a placeholder on the canvas. The code itself will only render when you go to preview, publish or export the site. Custom code does not run in the expand canvas view.
Why isn’t my script running on the live site?
There’s a separate page “Custom code not running on a Webflow site”. The quick checks are: has the site been published to the domain you’re looking at? Are you on a plan that allows custom code? Does the code contain any HTML, head or body tags? Does the browser console show an error? And if you’ve turned on “Asynchronously load JavaScript” does your inline code rely on Webflow’s JavaScript?
Can I have the same Google Analytics tag in two places?
Avoid it. Webflow recommend you add the GA4 tag in only one of two locations: either in the Google Analytics integration in Site Settings, Apps & Integrations or in your head code.
Can I use my own library?
Yes by loading the script. Check it against the jQuery version that Webflow loads.
Webflow plans and platform
Understand plans, limits, hosting and security.