Global scroll-to-top button for Squarespace 7.1

(looking to add a scroll button to just one page? Use this code!

πŸ“œ Modern Scroll Up Button for Squarespace

Copy and paste this into your Footer code injection inside your Squarespace site.

Installation & Customization Guide

How to Install

  1. Go to your Squarespace site's dashboard

  2. Navigate to Pages > Website Tools (scroll down to see) > Code Injection

  3. Paste the code into the Footer

  4. Click Save

Customization Options

Change Button Color

  1. Find this line in the CSS section: background-color: #14A19D;

  2. Replace the color code with your desired color. For example:

    1. Blue: #007bff

    2. Red: #dc3545

    3. Purple: #6f42c1

Change Arrow Design

  1. Find the SVG code in the JavaScript section:

    1. const svgContent = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">

      <path d="M12 19V5M5 12l7-7 7 7"/>

      </svg>`;

  2. Replace the SVG path with your desired icon. For example:

    1. Chevron: <path d="M18 15l-6-6-6 6"/>

    2. Circle: <path d="M12 8v8M8 12h8"/>

Adjust Position

  1. Find this line in the CSS: right: 20px;

  2. Adjust the value to move the button left or right

Change Scroll Trigger

  1. Find this line in the JavaScript: const shouldShow = window.scrollY > 300;

  2. Change 300 to your desired scroll distance in pixels

Troubleshooting

  • If the button doesn't appear, make sure the code is in the Footer Code Injection area

  • If the button appears but doesn't work, check your browser's console for errors

  • If the button appears in the wrong position, adjust the right and top values in the CSS

Notes

  • The button is mobile-responsive and will adjust its size on smaller screens

  • The button respects user preferences for reduced motion

  • The button is keyboard-accessible and screen-reader friendly

  • The button will appear below any sticky headers on your site

Safety & Compatibility:

  1. βœ… The code is self-contained and won't interfere with other Squarespace features

  1. βœ… It uses standard web APIs and vanilla JavaScript (no external dependencies)

  1. βœ… It's compatible with all modern browsers

  1. βœ… It respects user preferences (reduced motion)

  1. βœ… It's accessible and keyboard-navigable

  1. βœ… It has minimal performance impact

Disclaimers for Users:

Browser Support:

  • The smooth scroll behavior might not work in very old browsers

  • The button will still function, just without the smooth animation

Mobile Considerations:

  • The button appears slightly smaller on mobile devices

  • Position is adjusted for better mobile usability

Customization:

  • Users can change the button color by modifying the background-color value

  • The button position can be adjusted by changing the left value

  • The scroll trigger point (300px) can be modified if needed

Technical Notes:

  • The code should be added to the Footer Code Injection area

  • It will work on all pages automatically

  • No additional setup is required

Performance:

  • The code is optimized for performance

  • It uses passive event listeners

  • It includes debouncing for resize events

  • It has minimal impact on page load time

Looking for something custom? Let’s chat!