BACK TO Articles

Bring seasonal sparkle to your website with this simple script

By Tim McVinish

‘Tis the season for festive websites

Well, it’s the holiday season. While our homes, shopping centres, and everything else around us gets a sprinkle of holiday magic, websites are often overlooked. So today we’re going to explore creating a simple script that can be used to add a little festive flare to any website. This script will display a wreath and countdown to Christmas that, when clicked, triggers a whimsical snowflake animation. Let’s dive into the details!

Getting your digital decorating kit ready

Before we start decking the digital halls, let’s run through everything needed to add some festive flair to your website. You’ll need:

Essential tools

  • Access to your website’s code or the ability to add a script (more on that later)
  • A code editor
  • Basic understanding of HTML, CSS, and JavaScript
  • Holiday-themed images (PNG files with transparent backgrounds are preferred). We’re using a wreath.
  • Somewhere to host the image so our script can reference it

Step 1: Pulling out the digital decos

Just like with decorating the house, lets first open our cupboard and dig out our decorations. Personally I’m a minimalist, so we’ll keep things simple for this demo. Feel free to go as over-the-top-tacky-tinsel-too-many-fairy-lights-festive as you desire though.

const wrapper = document.createElement('div');
wrapper.id = 'the-wrapping';
    
const image = document.createElement('img');
image.id = 'digital-decoration';
image.src = '../../../assets/img/xmas-decoration-trimmed.png';

const countdown = document.createElement('div');
countdown.id = 'christmas-countdown';
countdown.textContent = 25 - new Date().getDate();
    
wrapper.appendChild(image);  
wrapper.appendChild(countdown);
document.body.appendChild(wrapper);

Here we’ve got a wrapper to contain everything, a png of a Christmas wreath, and a simple countdown display the sleeps till Christmas.

Step 2: Hanging the garlands

We’ll use a dash of super special Christams CSS to place our decorations on the page. This will include styles, positioning and animations. Again, feel free to add your own spin and create your own winter wonderland.

First, we need to define the styles for our Christmas-themed elements. This includes positioning, animations, and responsive design. Here’s how you can do it:


const styles = document.createElement('style');
  
styles.textContent = `
  #the-wrapping {
    position: fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    bottom: 50px; // position as you desire
    right: 50px; // position as you desire
    width: 120px; // size as you desire
    height: 120px; // size as you desire
    text-align: center;
    font-size: 1rem;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    z-index: 1001;
    cursor: pointer;
    user-select: none;
  }

  #digital-decoration {
    position: absolute;
    top: 2px;
    left: 6px;
    width: 114px;
    z-index: 1001;
    animation: sway 2s ease-in-out infinite;
  }

  #christmas-countdown {
    width: 118px;
    font-size: 2rem;
    font-weight: bold;
    color: #333;
  }

  @keyframes sway {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
  }

  .snowflake {
    position: fixed;
    pointer-events: none;
    animation: fall linear forwards;
    z-index: 1000;
  }

  @keyframes fall {
    to {
      transform: translateY(100vh);
      opacity: 0;
    }
  }
`;
document.head.appendChild(styles);

Step 3: A sprinkle of javascript magic

Those with a keen eye may have noticed the snowflake class in our css. “But there were no snowflakes in step 1!?”. This is for a final touch, a fun little click animation that creates a snow shower upon clicking our festive finishings. With that said, let’s add a listener for click events on our decorations and then trigger a createSnowflake function.

const christmasDecoration = document.getElementById('the-wrapping');
christmasDecoration.addEventListener('click', () => {
  // Create snowflake effect
  for (let i = 0; i < 10; i++) {
    createSnowflake();
  }
});

function createSnowflake() {
  const snowflake = document.createElement('div');
  snowflake.innerHTML = '❄';
  snowflake.className = 'snowflake';
  snowflake.style.left = `${christmasDecoration.offsetLeft + Math.random() * 110}px`;
  snowflake.style.top = `${christmasDecoration.offsetTop}px`;
  snowflake.style.fontSize = `${Math.random() * 10 + 10}px`;
  snowflake.style.animationDuration = `${Math.random() * 8 + 1}s`;
    
  document.body.appendChild(snowflake);
    
  // Remove snowflake after animation
  setTimeout(() => {
    snowflake.remove();
  }, 3000);
}

Now, when our decorations are clicked a flurry of frosty flakes will float over our site. Magical!

Step 4: Spread the Christmas cheer

Now, how do we deploy this? Well that will depend on where your site lives. If you have access to your code base then you can simply wrap the script in some <script> tags and paste it where you please. If you’re using a platform like WordPress, Wix, or Squarespace, then you should be able to inject a script into your site via your dashboard. Below are some guides for these platforms. If you’re using a different platform Google should be able to help you out. Most platforms will provide a way to inject scripts.

And that’s a wrap! Please feel free to share any magical creations or alterations you come up with.

Guides for adding scripts to popular website platforms:

The complete script

(function () {
	// content
	const wrapper = document.createElement('div');
	wrapper.id = 'the-wrapping';
    
	const image = document.createElement('img');
	image.id = 'digital-decoration';
	image.src = './path-to-your-image/your-image.png'; // replace with the path                            
        to your image

	const countdown = document.createElement('div');
        countdown.id = 'christmas-countdown';
        countdown.textContent = 25 - new Date().getDate();
    
        wrapper.appendChild(image);  
        wrapper.appendChild(countdown);
        document.body.appendChild(wrapper);
  
        // styles
        const styles = document.createElement('style');
  
        styles.textContent = `
	    #the-wrapping {
	      position: fixed;
	      display: flex;
	      align-items: center;
	      justify-content: center;
	      bottom: 50px;
	      right: 50px;
	      width: 120px;
	      height: 120px;
	      text-align: center;
	      font-size: 1rem;
	      background-color: rgba(255, 255, 255, 0.9);
	      box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
	      border-radius: 50%;
	      z-index: 1001;
	      cursor: pointer;
	      user-select: none;
	    }

	    #digital-decoration {
	      position: absolute;
	      top: 2px;
	      left: 6px;
	      width: 114px;
	      z-index: 1001;
	      animation: sway 2s ease-in-out infinite;
	    }

	    #christmas-countdown {
	      width: 118px;
	      font-size: 2rem;
	      font-weight: bold;
	      color: #333;
	    }

	    @keyframes sway {
	      0%, 100% { transform: rotate(-5deg); }
	      50% { transform: rotate(5deg); }
	    }

	    .snowflake {
	      position: fixed;
	      pointer-events: none;
	      animation: fall linear forwards;
	      z-index: 1000;
	    }

	    @keyframes fall {
	      to {
	        transform: translateY(100vh);
	        opacity: 0;
	      }
	    }
	  `;
	   document.head.appendChild(styles);

	  // functionality
	  const christmasDecoration = document.getElementById('the-wrapping');
	  christmasDecoration.addEventListener('click', () => {
	    // Create snowflake effect
	    for (let i = 0; i < 10; i++) {
	      createSnowflake();
	    }
	  });

	  function createSnowflake() {
	    const snowflake = document.createElement('div');
	    snowflake.innerHTML = '❄';
	    snowflake.className = 'snowflake';
	    snowflake.style.left = `${christmasDecoration.offsetLeft + Math.random()   
            * 110}px`;
	    snowflake.style.top = `${christmasDecoration.offsetTop}px`;
	    snowflake.style.fontSize = `${Math.random() * 10 + 10}px`;
	    snowflake.style.animationDuration = `${Math.random() * 8 + 1}s`;
    
	    document.body.appendChild(snowflake);
    
	    // Remove snowflake after animation
	    setTimeout(() => {
	      snowflake.remove();
	    }, 3000);
	  }
	})();

Looking for something specific?

Search our Archive to find content that piques your interest.
SEARCH

Recents Posts

October 7, 2025
Unified Service Desk is retiring – What does that mean for you?
If you’ve worked in the Microsoft Dynamics 365 ecosystem over the past decade, chances are you’ve encountered Unified Service Desk (USD), that trusty Windows-based tool that brought multiple customer service systems into a single interface for agents.  Microsoft has made it official:  Unified Service Desk is being retired. Deprecation begins: April 1, 2026 End of support: June 30, 2028  💡 Why it matters  USD has been a…
Read more
September 29, 2025
Exploring Agile Work Items in Azure DevOps
Azure DevOps is a flexible and powerful platform which offers a wide range of tools and features for managing software development projects. One of its key components is the Work Items feature, which helps Agile teams plan, track, and manage their work efficiently. Work Items in Azure DevOps are highly customisable, allowing teams to tailor their workflows following Agile methodologies.   We…
Read more
September 25, 2025
Half a day to kick start your commitments
Budgets are locked. Initiatives are signed off. Now comes the hard part: delivering on your commitments. Our MojoSpark Workshop is designed to help you and your team cut through the noise and move forward with confidence. What we’re hearing…. In just half a day you’ll walk away with: Start your transformation today — this is…
Read more
September 22, 2025
Five roadblocks stopping your POC from going into production
Most organisations are great at generating ideas. Many are good at testing those ideas through proofs of concept (POCs) but few manage to take those POCs into full production, where the real business value lives. Why? Because going from concept to production is about scaling, sustaining and embedding it in the business. We get a…
Read more