Skip to main content

Snippets & Hacks

Small, self-contained code blocks for Webflow. Each snippet is placed via an HTML Embed element or Page Settings custom code — no npm, no build step.

SnippetWhat it does
Back ButtonBrowser history back navigation via onclick="history.back()"
Scroll to TopSmooth scroll-to-top button that appears after the user scrolls down
Active Nav HighlightAdds w--current to nav links matching the current URL
Form Disable on SubmitPrevents double-submissions by disabling the submit button on first click
Reading TimeShows estimated reading time derived from CMS rich text content
External Link TreatmentAuto-adds target="_blank" and rel="noopener noreferrer" to outbound links
Text HighlightingCMS-driven word and phrase highlighting in headings
Swiper CarouselHorizontally scrollable card carousel with numbered pagination bullets

Pattern

All snippets follow the same approach:

  1. Style any visible element (button, span, div) in the Webflow Designer with your own classes.
  2. Place an HTML Embed where the element should appear and paste the snippet code, swapping in your class names.
  3. For page-level scripts (active nav, form disable, reading time, external links), add to Page Settings → Custom Code → Before </body> instead.

Webflow strips onclick and other event attributes from its native Button and Link elements on publish. Always use an HTML Embed for interactive elements.