Beacon Buddy

Tricks & Treats For Web Development: A Halloween Blog

Est. Reading Time: 1 minute

Happy Halloween from Beacon! Today’s topic: Tricks and Treats for web development. For a particularly ghastly fade loop it’s common to see recursive code that calls itself, but that results in a large amount of memory wasted just to maintain the call stack which will also eventually crash the page. Instead binding a pair of fade calls to the change function with a callback to trigger itself can save you all that memory overhead and achieve a steadier effect.

    $(document).ready(function () {
        $(".ghosty").change(function () {
            $(this).fadeTo(3000, 0.3).fadeTo(3000, 1.0, function () {

This code will loop constantly and can be used for many other things besides simply fading a picture of a ghost in and out.

For an easy way to add some fright to your site add some scary witches or haunting black cats that will slide into view on hover on a sibling element to make the cat or witch peek out from behind an innocent nav menu or block of text. For more ideas on how to spook your audience check out the link below:

One Trackback