All that gets put in the external js file are the functions, not the js w/in
the html. So if you are using the same functions on different pages you just
put all the functions into one .js file and link it to all pages. Let's say
every page swaps images, 1 page has a DHTML scroller using LayerAnimagic, they
all us a js-updated clock, 2 pages have a flyout menu using show/hide layers or
autolayers...whatever. Remove all the javascript from between the comment tags
and put it in a new .js file. Then look through the list of functions in your
new file and make sure there aren't any repeats of the same function. All swap
image functions look the same. All show/hide layer functions look the same,
etc.
The start:
function MM_preloadImages or
function MM_findObj(n, d) { //v4.01 or
function P7_autoLayers() { //v1.4 by PVII or
function MM_swapImage() { //v3.0 or
function MM_swapImgRestore() { //v3.0
It's fairly easy to see if there are repeats in there. If it's not, put the
first line of a function into find and replace and click Find. If there's a
duplicate, delete it. Really quite simple, actually.
Then attach it to your pages (I put mine directly beneath my style sheet
links):
<script type="text/javascript" src="yourfile.js"></script>
--
--
DiMa
--------------------
WEB FORUM USERS: Please log on to the Newsgroup for quicker replies to your
posts:
news://forums.macromedia.com/macromedia.dreamweaver
For Answers, check here first:
http://groups.google.com/advanced_group_search?q=+group:macromedia.dreamwea ver
http://www.macromedia.com/support/dreamweaver/technotes.html
http://www.projectseven.com/faqbase
http://www.dreamweaverFAQ.com
http://www.macromedia.com/support/forums/etiquette.htm
DiMa Design > From Lines...to Designs
http://www.dimadesign.net
"Heru" <webforumsuser (AT) macromedia (DOT) com> wrote
Quote:
It has been reccomended that I should place all my javascript in external
files to speed up loading times. At the moment I have been creating an
|
individual javascript for each page on my site (Using MX). It has ocured to me
that much of the javascript for each page looks the same, and I was wondering
if similar pages could share the same external javascript.
Quote:
As I don't understand what most of the javascript means it is difficult for
me to tell if the javascript is indeed identical. Most of the pages on my
|
website are based on a few varying formats, so logic would dictate that similar
pages could possibly share an external javascript file. If you look at my
pages,
Quote:
http://www.artsablaze.co.uk/about_arts_ablaze.htm
and
http://www.artsablaze.co.uk/david_hier_profile.htm
, both pages are almost identical except for content. There are plenty of
pages on my site that are similar to one another, so can they all share a few
|
pages of javascript.
Quote:
Any advice would be appreciated.
Dave
Referring URLs
http://www.artsablaze.co.uk/
http://www.artsablaze.co.uk/about_arts_ablaze.htm
http://www.artsablaze.co.uk/david_hier_profile.htm |