Take the 2-minute tour ×

I'm re-developing a very simplistic javascript include I made a while back to be used in several similar html sites. We use a lot of footers on our pages but they tend to be the same copy used over and over but with different dates and other small variations. So, on each page I create an array of variables. These match up with variables found in an external .js file containing a for loop to match up the requested variables that contain paragraphs of footer copy. This eventually is put together to make a div full of footer copy.

My question is this, is it better to send in the specific dates and other variable changes within the copy along with the variable array as one object or should i continue to just send in the variable array alone, create the footer in the html and then insert the dates/changing data in a separate .js file (this is how I've been doing it till now). One way keeps all the data together and seems pretty clean, but the other separates out the different steps (ie step one is creating the footer, the second step puts in the varying info like a date or bonus amount, etc).

sorry if this is confusing, hope i got the basic idea across. Just trying to explore my options since I have the unique opportunity of previous usage of this script and getting a clean slate to make a fresh version.

share|improve this question
One useful snippet of code is worth .. –  user166390 Nov 10 '12 at 3:20

1 Answer 1

I think the best way to do this is on the server-side code.IF you are using php use could include the file directly like this.What include does is it pull code from other files and shows it on the page where the include is written.

include('name of file');

Since you have different pages with different footers you could edit this footer file to show different results for different pages.This is a standard way to doing things.Popular frameworks like Wordpress do something similar to this to display the footer

share|improve this answer
Thanks for the feedback! I currently use an include for the external js. We're limited to using client-side dev so javascript is all we use for this kind of coding (hence the options of only objects or variables.) Sorry i didn't specify that in the beginning. I think I'm going to go with an object though. I can send in a lot of info at once to the external js file by sending one object rather than a ton of variables. My objective is less/cleaner code, easier to read and easier to pick up even if you didn't develop the page from the beginning. I guess those are pretty typical objectives :) –  morgen Nov 10 '12 at 6:33

Your Answer


