Grow your CSS skills. Land your dream job.

Where do you place global variables?

  • # June 12, 2013 at 1:09 pm

    Hello,

    Curious to know if there is a preferred practice for the location of global variables. I like to organize variables at the top of all my functions…just inside the document ready. Is this the best method? Or is it better to place variables right before the associated function?

    Any advice is welcome…thank you

    # June 12, 2013 at 1:16 pm

    I put all global variables at the top of the JS file, before the document ready (unless, of course, they require the document to be ready).

    # June 12, 2013 at 3:44 pm

    As a general rule, I avoid global variables whenever possible, to keep things neatly organized and prevent potential name conflicts.

    # June 12, 2013 at 7:06 pm

    Ok…thanks for the advice!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".