Jump to content

Basic Question


chordsoflife

Recommended Posts

I like to code in XHTML 1.0 Strict... for whatever reason. I'm building my first substantial web application, so I'm running into a few things I've never had to deal with before.

 

Right now my issue is how many different external files I load in my header file and include in every page. It feels wrong to me to include so many different things that I don't use on a particular page, and it seems equally crazy to if statement them in for the particular pages I need them on.

 

Is there a correct way to organize and include these kinds of things?

Link to comment
Share on other sites

Do you mean how do we have include files and make sure that we don't include something we don't need, simple in the include file (header or whatever) just put something that you will need on all pages, and everything else on the page in question. Now if you have something on more than one page but not all then make a function for that and put it in the include file.

Link to comment
Share on other sites

Hm, let me try to be more clear.

 

My header file has everything up to the page div. Typical. The page itself has whatever it needs. The footer file has the page close div and beyond.

 

If I have one page that requires some js in a script tag (just that ONE page), I can put it on the page that needs it, but it's below the /head tag, which invalidates the page. To put it in the head tag, it would have to be in the header file, which means it would load unnecessarily for all the other pages.

 

So lets say I have 20 unique pages that all use 20 unique bits of JS. Now I've got a 19 scripts loading for a page that don't need to be. Is it correct to put each one in an if statement so if page = whatever load this script?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.