Black Friday30% off every Squarespell plugin. No code neededOr get all 49 plugins from $15/mo, 14 days freeEnds in01d02h34m49sShop plugins
squarespell
Confetti-Pop! Button to Pinterest (opens in a new window)

Confetti-Pop! Button

Plugin Squarespace

Squarespell

Free

Free

Get the free code

Squarespell Original. made, sold and supported by us.

How we label paid placements

  • Built for Squarespace

    Listed against the platform it was made for.

  • Free from Squarespell

    Published and maintained by us.

Overview

What this plugin does for your Squarespace site.

Learn how to create fun and interactive Confetti Pop buttons on your Squarespace 7.1 website.

Full description

In the creator’s words.

Confetti-Pop! Button

1. Add this code to Website Tools → Code Injection → Footer

JavaScript67 lines
<!-- Add the confetti library -->
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.5.1/dist/confetti.browser.min.js"></script>

<!-- Add this JavaScript code -->
<script>
document.addEventListener('DOMContentLoaded', function() {
    // Function to trigger confetti
    function triggerConfetti(e) {
        // Prevent default link behavior
        e.preventDefault();
        
        // Trigger confetti
        confetti({
            particleCount: 100,
            spread: 70,
            origin: { y: 0.6 },
            colors: ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff']
        });

        setTimeout(() => {
            confetti({
                particleCount: 50,
                angle: 60,
                spread: 55,
                origin: { x: 0 }
            });
            confetti({
                particleCount: 50,
                angle: 120,
                spread: 55,
                origin: { x: 1 }
            });
        }, 150);

        // Navigate to the link after a small delay
        setTimeout(() => {
            window.location.href = e.target.href;
        }, 300);
    }

    // Find the button using the specific class
    const buttonSelector = '#block-yui_3_17_2_1_1728728185968_2536 .sqs-block-button-element';
    
    function attachEvent() {
        const button = document.querySelector(buttonSelector);
        if (button) {
            button.addEventListener('click', triggerConfetti);
            console.log('Confetti effect attached successfully');
        } else {
            console.log('Button not found');
        }
    }

    // Try to attach immediately
    attachEvent();

    // Also watch for dynamic changes
    const observer = new MutationObserver(function(mutations) {
        attachEvent();
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
});
</script>

Guide to Replace #block-id for Confetti Animation:

Locate the Block ID of Your Button:

Open your Squarespace website in a browser.

Right-click on the button you want to trigger the confetti animation and select Inspect or Inspect Element.

Look for a parent element or the button itself with an id attribute. It will look something like id="block-yui_3_17_2_1_1728728185968_2536".

Copy the Block ID:

Highlight and copy the id value (e.g., block-yui_3_17_2_1_1728728185968_2536).

Replace the Existing Block ID in the Code:

Locate the line in your JavaScript code where the button selector is defined:

How to add Confetti Pop! Buttons in Squarespace 7.1

Replace #block-yui_3_17_2_1_1728728185968_2536 with the copied Block ID from Step 2.

Verify the Button Class:

Ensure that the .sqs-block-button-element class is still valid for your button. This class is commonly used for buttons in Squarespace but may vary depending on your template or custom styles.

If your button uses a different class, update the selector accordingly, e.g., #your-block-id .your-button-class.

Test the Confetti Animation:

Save the updated JavaScript code and refresh your website.

Click the button to ensure the confetti animation triggers as expected.

If it doesn’t work, double-check the Block ID and the button’s class.

Optional: Watch for Dynamic Changes:

If your button is dynamically loaded (e.g., part of a popup or AJAX-loaded content), the provided script includes a MutationObserver to detect changes in the DOM. No further action is required to handle this unless you need to customize the observer

Check it fits before you buy

  • Platform

    Squarespace

    Not available for any other platform.

  • Product type

    Plugin

  • Account needed

    Squarespace account

    Bought separately from the plugin.

  • Delivered by

    Squarespell checkout

Squarespell

Squarespell product Squarespace specialists

Built and supported by Squarespell. Sold here directly, so support and updates come from us rather than a third party.

Evidence

Customer reviews & feedback

No Squarespell customer reviews yet.

Write a review
Your rating

Only people who bought this plugin can review it. No account needed.

Squarespell reviews

Nobody has reviewed this here yet. Be the first, we only publish reviews left on Squarespell in this section.

Before you buy

The questions buyers ask most about this plugin and about buying through Squarespell. Anything about the product itself is answered by Squarespell.

Buying through Squarespell

Where do I complete the purchase?

Through Squarespell checkout.

Ready to look at Confetti-Pop! Button properly?