Community Library

Welcome to the Community Library, home to Webflow-specific JavaScript solutions. Explore the ever-growing collection of real-world examples, utilities, and plugins created by Slater users. Whether you're looking for inspiration, facing a coding challenge, or want to learn from others, the Community Library is a collaborative resource to help you unlock the full power of JavaScript.

Join Cory Moen, Digidop, Jeff McAvoy, and Jared Malan, and contribute your own solutions. To contribute, add your scripts to your personal library and then reach out to us on Twitter or Slack.

Ellipsis text
CSS class to truncate text with ellipsis when it overflows the container width.
css
text overflow
ellipsis
single line text
By Jared Malan
Rive - Set Text Run Value
Update the string of text used in a Rive text run at runtime
text processing
string manipulation
document editing
dynamic content update
By Jeff McAvoy
Copy to Clipboard
Copy text to clipboard on button click with visual feedback and console log.
clipboard api
event handling
By Jared Malan
Pointer events
CSS classes to control pointer events: .pointer-events-off disables interactions, .pointer-events-on enables interactions.
css
pointer-events
interactivity
user interaction
By Jared Malan
Rive Input - Create Variable by Name
Create a variable for your state machine inputs by input name.
rive
input
By Jeff McAvoy
Tabs switch on hover
JavaScript code for a hover-based tab interface with dynamic content display.
tabs
hover events
dynamic content display
By Andrea Morgan
Animated American Flag
Render and animate an American flag on a canvas with dynamic waving effects.
html5 canvas
animation
american flag
By Jared Malan
Click Something Based on ID in URL
Automatically triggers a click on an element if URL hash matches "#example".
url hash
click event
web development
By Corey Moen
Fix Paragraph Runts With Nonbreaking Space
Prevent single-word runts in HTML elements with the class `.no-runt`.
jquery
typography
By Corey Moen
Pause/Reset Video Embed on Click
Stops all iframe videos by resetting their source on '.close-video' button click.
video control
By Corey Moen
Auto-collapse accordion in Webflow
Toggle accordion elements with a click, ensuring only one can be open at a time.
accordion
ui behavior
By Digipop
Hide element if collection is empty
Hide sections based on dynamic content state using jQuery.
dynamic content
visibility toggle
By Corey Moen
Number to Currency
Formats a string input as US dollar currency without decimal places.
currency formatting
error handling
validation
By Jared Malan
Restart IX2
Reset, initialize, and prepare Webflow interactions for optimal functionality.
webflow
interactions
By Web Bae
Basic scrollTrigger setup
Animate elements based on scroll position using GSAP and ScrollTrigger.
gsap
scrolltrigger
web animation
scroll-based animation
By Digipop
Click Something When Pressing ESC Key
Triggers a click on a specified element when the 'Escape' key is pressed.
event listener
keydown
By Corey Moen
Fetch - Delete
Delete a resource via API using JavaScript's fetch with DELETE method.
api
fetch
delete
By Jared Malan
Copy to Clipboard
Copy text to clipboard on button click with visual feedback and console log.
clipboard api
event handling
By Jared Malan
Reveal Words on Scroll
Animate text on scroll with GSAP, ScrollTrigger, and SplitType.
gsap
scrolltrigger
text animation
By Witt Langstaff
Validation - Phone
Validates phone number format and handles errors on input field blur.
validation
regular expression
event handling
By Jared Malan
Page Change Click Delay
Delay anchor navigation by 500ms for specific classes to allow processes like animations.
jquery
event handling
navigation delay
By Corey Moen
Rive Input - Update Number
This code lets you update the value of a Rive number input variable.
rive
javascript
input
By Jeff McAvoy
Currency to Number
Convert currency string to number by removing non-digit characters and parsing to float. Throws error for invalid input.
currency conversion
string manipulation
error handling
By Jared Malan
Set Hidden Input Value From URL Parameters
Retrieve URL parameter and set it to a hidden input field.
url parameters
regular expressions
By Corey Moen
Validation - Email
Validates email format and handles invalid input on blur event.
email validation
regular expression
jquery
event handling
By Jared Malan
Handle Resize
Optimizes window resize handling by debouncing rerendering of elements.
debouncing
performance optimization
event handling
By Jared Malan
Track User Localstorage
Tracks user navigation and populates a form field with the history.
user journey
localstorage
form population
url tracking
By Jared Malan
Lenis Smooth Scrolling
Smooth scrolling setup using Lenis library with scroll event logging.
lenis
smooth scrolling
animation
By Jared Malan
Interactive Squares
Create a dynamic grid of elements that react to mouse movement, simulating a swarm-like effect.
mouse events
dynamic styling
grid layout
swarm
By Jared Malan
Filter Out Selection
Filter array elements matching button text on button click.
dom manipulation
event handling
array filtering
By Jared Malan
Load All CMS Items
This JavaScript code parses and displays CMS items from a webpage, storing them in an array and rendering them in a specified div.
jquery
cms
web scraping
dom manipulation
By Jared Malan
Navbar color change depending on hovered section
Dynamically update element colors on scroll based on visible section attributes.
dom manipulation
event handling
scroll events
dynamic styling
By Digipop
Expand text on click
Toggle visibility of text sections with "Read More" buttons using JavaScript.
read more button
expandable text
class manipulation
By Andrea Morgan
Auto update copyright year
Dynamically updates an HTML element to display the current year using JavaScript.
date object
dynamic content update
By Digipop
Fetch - Get
A JavaScript code snippet that fetches data from a URL, converts the response to JSON, and logs the data or any error to the console.
fetch api
promises
json
error handling
By Jared Malan
Hide scrollbars
CSS class to hide scrollbars
css
scrollbar
By Jared Malan
Text Highlight Color
CSS code for high-contrast text selection: black background and white text.
css
::selection
text selection
By Jared Malan
Print Page Button
Trigger browser print dialog on clicking element with ID 'print'.
printing
By Digipop
Bind function to window
Defines an empty global function doSomethingInAnotherFile.
global function
window object
By Jared Malan
Refresh after form submit
Automatically refreshes the page 7 seconds after any form submission.
form submission
page reload
By Corey Moen