Sunday, December 8, 2013

How I added the Animated Snowfall Effect on my Blog

   If you are one of our very observant blog readers & visitors, you will notice that there is a very unusual effect on any page you are visiting on this blog at this very moment. Even as you are reading this post, you will notice the snow falling on this page. What does it mean ? and How could that be ? Well, the snowfall is just a beautiful effect that can be added to a blog during periods like this. I mean we are already approaching the festive weeks and don't you think its a good idea to welcome and entertain your visitors with a beautiful animated effect like this 'SnowFall Animation'. You already see how it works, the snow smoothly falls down the page and then disappears. Perfect !!!
Snowfall Effect
   If you are also interested in adding this animated effect to your Blog then you're at the right place because this tutorial will teach you how to easily set up this animated snowfall on your blog in less than 5 minutes. Note that we can control the number of snowflakes and we can also replace the snowflakes image with any image you prefer [maybe falling leaves, flowers or something attractive]. Now, Lets get started.

How to Add the Snowfall effect to your Blog.

  1. Login to Blogger and Click on 'Layout'.
  2. Click on 'Add a Gadget' at the uppermost part of your blog.
  3. Now, Choose 'HTML / JavaScript' from the list shown.
  4. Paste the following code inside it.
<script type="text/javascript">
    //Configure below to change URL path to the snow image
  var snowsrc=""
  // Configure below to change number of snow to render
  var no = 15;
  // Configure whether snow should disappear after x seconds (0=never):
  var hidesnowtime = 0;
  // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  var snowdistance = "pageheight";

///////////Stop Config//////////////////////////////////
  var ie4up = (document.all) ? 1 : 0;
  var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 800, doc_height = 600;
  if (ns6up) {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  } else if (ie4up) {
    doc_width = iecompattest().clientWidth;
    doc_height = iecompattest().clientHeight;

  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();
  snowsrc=(snowsrc.indexOf("")!=-1)? "" : snowsrc
  for (i = 0; i < no; ++ i) { 
    dx[i] = 0;                        // set coordinate variables
    xp[i] = Math.random()*(doc_width-50);  // set position variables
    yp[i] = Math.random()*doc_height;
    am[i] = Math.random()*20;         // set amplitude variables
    stx[i] = 0.02 + Math.random()/10; // set step variables
    sty[i] = 0.7 + Math.random();     // set step variables
        if (ie4up||ns6up) {
      if (i == 0) {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
      } else {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");

  function snowIE_NS6() {  // IE and NS6 main animation function
    doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
        doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      yp[i] += sty[i];
      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = 0.02 + Math.random()/10;
        sty[i] = 0.7 + Math.random();
      dx[i] += stx[i];
      document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px"; 
    snowtimer=setTimeout("snowIE_NS6()", 10);

    function hidesnow(){
        if (window.snowtimer) clearTimeout(snowtimer)
        for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"

if (ie4up||ns6up){
        if (hidesnowtime>0)
        setTimeout("hidesnow()", hidesnowtime*1000)

   5. Note that you can make some changes in the Snowfall script above, changes like -
  • To set the number of Snowflakes, change 15 to the number of snowflakes you want.
  • To change the snow image, replace the link in bold with your image's link.
   6. Now, you should click on Save and You'll see the newly added animated snowfall on your Blog. 

   What do you think about this animated snowfall effect ? Do you like it ? Do you have any problem installing it on your Blog ? Kindly drop your comments, I'll be glad to help you and don't forget to share this important post with others.


  1. Nice one... I'm using the effect on my wordpress blog too but my background is white so LOL... I may change my theme soon and maybe it will show.. Yours looks great

    1. Thanks a lot for dropping by, Uju. I also noticed the effect on your Blog the last time i visited, that was when i even said to myself - common, i gotta put this on mine too. Then I put it on #SBCN. Hope to see a very professional and attractive theme on your Blog soon.

  2. wooow it look cool and nice av added it to my blog.

    1. OK, Glad you like it Bro. It also looks nice on your Blog, Nice Blog !!!

  3. Does it appears on mobile view of a blog?

    1. Hi Temmy,

      Yes, If viewed on a standard mobile browser with JavaScript enabled.


Drop Your Contributions, Opinions and Suggestions Here !

Want to be notified when I reply your comment ? Then tick the "Notify Me" box.

Cheers !!!