The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

putting them in seperate files wont speed it up much but it will be much much easier to manage. the adavantage of putting them in a seperate file is that if you ever need to change the code you just have to update the file once and its all done so you dont have to go to all the other files and edit them.

put your javascript code in a textfile with the extension .js to include it use

Code:

<script language="javascript" src="path/to/mysrc.js"></script>

to include css put all the css definitions in a file with the extension of .css then in the head of your code put

Actually putting them in separate files could slow things down (more separate server calls) but it is much tidier!

Side point really.

Quick DW tip. If you want to squash their code a little, find and replace all occurances of MM_ with nothing. Saves you 3 bytes every time a DW script refers to or creates a function or variable. It can add up!

That obviously cuts out some browsers - but i don't really tend to care about them.

The swap image function is bulky - the preload function should do the variable declaration of objects and the swapimage funciton should just be one single line - would someone else like to outline this - kinda busy right now

Originally posted by Flawless_koder That DW generated script is bulky and inefficient.

Originally posted by Flawless_koder findObj would work just as well as

funciton de(obj){ return document.getElementById(obj); }

That obviously cuts out some browsers - but i don't really tend to care about them.

Actually, the code above is excellent piece of programming, and is designed to cope with every browser known to mankind (as long as it has JavaScript)!! Making unsubstantiated statements like your first (reproduced above) doesn't really tell anyone anything, other than your personal opinion. (Which you are of course entitled to)

And in your second statement, just because you don't care about your code running in anything other than W3C DOM level 1 compliant browsers (i.e. it will only work for IE 5+ and Netscape 6+ !!!) doesn't mean that these issues are irrelevant to AndyT (or other people)!

While greg.harvey's tip about replacing the "MM_" prefix may at first sound like a good plan, Macromedia added this prefix not only because they invested time and money writing the code (and thus want to leave their mark), but also because the JS "Behaviour" system that DreamWeaver & Fireworks both use relies upon the presence of the MM_ prefix to distinguish between its own JS functions and user written "Custom Script" code. Thus, although removing the prefix from the code may save a minute amount of space, it will actually stop you being able to edit assigned behaviours in DreamWeaver/Fireworkds, and is therefore best left alone! (Incidentally, placing it in a separate JS include file will also disrupt the "Behaviour" functionality.)

IMHO there is no need to touch any of this code at all, since it is as cross-browser as it is possible to be, it is efficient, and is required by the behaviours you have applied (indeed, the code will be regenerated by DW/FW every time you modify the relevant behaviour anyway)! It also comes to less that 1K in size, which in terms of download time is utterly insignificant.

I rest my case, m'lud!

Flawless - if you are indeed able to come up with code which does everything that the DW code snippets above do and is somehow "better" in some measurable way as well, then please post it, or sell it to Macromedia so that we can all benefit!!!

Just noticed that you mentioned CSS as well. This should indeed be moved to an external file, so that you only have to change that one file to effect a change to the formatting of the entire site - ease of administration is the major advantage here, not speed of download (although this will be marginally improved, but not significantly).

Is it possable to put the script further down the HTML page, as ive heard that search engines spider from the top down and that all content should be nearer the top of the page as possable for better SEO. Is this why its another good idea to put code in a seperate file?