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.

Single JS file

I've a site with a large number of external JS files, and I'm trying to reduce them into one single file, or at least less than the 22 there currently is.

Since most of them are plugins for wordpress I can only really minimalise my theme ones.

One issue I'm having is that the ddsmoothmenu.js I've cut+paste the code into a new javascript file (where I've moved some other JS coding, including the init() for ddsmoothmenu) however since doing that its just... dud. My menu is there but none of my hoverouts now work.

I'm rather a JS newbie still so if someone could please explain to me why my ddsmoothmenu JS coding isn't now working I'd be very grateful.

Please post a link to a page on your site that contains the problematic code so we can check it out.

As for consolidating .js files, that's usually fine. To avoid errors it helps to know a bit about javascript though. Generally one may just list the scripts concurrently in the file.

A word of caution about minifying (if that's what you really mean, it's a technical term referring to the use of jsmin or similar minifying algorithms). Only code that follows some of the strict standards for the placement of the semi-colon and sometimes even brackets will minify well. There are exceptions and this can depend upon the minifying tool used, but it's best to use strict syntax overall. You will end up with a smaller file in the end in most cases, and it will almost always still work - a big plus. See JSLint:

What you could do is view the problem page in the browser. Use it's 'view source'. Copy and paste that to a .txt file and upload it here for us to look at. If it's too big, zip it first. It's not nearly as good as the live page, but it might show us something we can help you with.

One thing I'd check in that though, but only you can do it, is look at the external script tag in that view. Does it point to the actual location of the script? Do other file paths (like images, css files, etc.) point to the actual files?

If you have a browser with diagnostic tools, you should be able to look at the scripts to see if their contents is what's expected.