Here's an article that I've been meaning to post to the list anyways, but I
guess this is a great opportunity to do so.
http://www.hunlock.com/blogs/Supercharged_Javascript
It is a somewhat advanced article, and the example uses htaccess+PHP, but
you could use pretty much any server language. It's hard to give a brief
synopsis about the technique described, but essentially instead of having n
script tags for each JS file, you would simple do:
<script src = "scripts/file1.js, file2.js, file3.js etc"></script>
The server-side part of the implementation takes that as a list of
arguments, checks to see if any of the JS files have been replaced with a
newer version, checks if a cached version exists; and if any of that fails,
it combines all the files listed into a single gzip'd (compressed) file,
which it caches for reuse. It then of course sends it to the browser.
I've read alot of really great articles on that blog, I'd recommend it to
everyone.
On 2/14/07, Kristinn Sigmundsson <[EMAIL PROTECTED]> wrote:
Hi there.
I'm working on a site that will be using alot of ajax for
edit-in-place, aswell as alot of other javascript. The thing is that
there is practicly no javascript for regular users, compared to
administrators. So I figured that in the top of my indexfile where all
the scripts are I'd do something like this:
<?php
if ($user->getRights('news')
echo '<script src="newsScripts.js" type="text/javascript></script>';
?>
for every page that needs javascript. The thing is that for this to
work properly (and without having the same code on different places) I
have to split some .js files down to each function.
Is this a good idea in the first place, having (at most) up to 10 <script>
tags?
Would it be better to make a big file for all the adminfunctions when
the development is done (compressed it is abt 20kb, not including
jQuery and a few plugins).
I kinda the latter better. Then I can have a file that is common.js
with all my common functions and different scriptfiles for more
specific stuff. But when the development is done I put them all to one
adminstration.js file and compress it.
What are your thoughts on this? How do you manage your javascript in a
development, on a running site?
Would be pleased with every input you make.
// Kiddi
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/