Removing unused JavaScript in Webflow is an effective way to speed up your site and improve the Time to Interactive (TTI) metric in Core Web Vitals.
1. Audit With PageSpeed Insights or Lighthouse
- Use Google PageSpeed Insights or Lighthouse in Chrome DevTools to identify unused JavaScript.
- Focus on scripts flagged under "Reduce unused JavaScript" or "Remove unused third-party code".
2. Disable Unused Webflow Features
- Webflow includes JavaScript for certain features by default (e.g., sliders, tabs, interactions).
- Delete unused components from your pages and symbols. For example:
- If you’re not using the Slider, remove all instances of it.
- If you’re not using Webflow Forms, delete all form components and associated logic.
- Removing the visual component also removes its supporting JavaScript.
3. Avoid Interactions That Inject Runtime Code
- Webflow Interactions can generate additional JavaScript at runtime.
- If you're using interactions for simple effects (like reveal-on-scroll), consider replacing them with CSS transitions or native scroll animations.
- The less Interaction logic you use, the leaner the generated JavaScript.
4. Reduce Third-Party Scripts
- Minimize or eliminate third-party embeds like chat widgets, marketing pixels, or analytics scripts that add extra JS.
- If necessary, defer or use lazy-loading techniques:
- Use integrations like Google Tag Manager to load scripts conditionally.
- For YouTube/Vimeo embeds, use the Webflow native lazy-load settings (e.g., set loading="lazy" and use the
?rel=0 URL param when possible).
5. Use Webflow’s Custom Code Area Strategically
- Avoid placing unnecessary or outdated JS in Page Settings > Custom Code or Site Settings > Custom Code.
- Only use scripts that are critical for functionality or tracking.
6. Consider Publishing to Staging First
- Webflow styles and scripts can vary between Editor mode, Designer preview, and live published sites.
- Always measure performance on the live published version to get accurate JS usage data.
Summary
To remove unused JavaScript and improve TTI in Webflow, eliminate unused components like sliders and forms, reduce interaction usage, limit third-party scripts, and clean up any added custom code. Start by auditing with PageSpeed Insights to target specific JS you can cut from your project.