[kupu-dev] Kupu 1.4 beta 3

Duncan Booth duncan.booth at suttoncourtenay.org.uk
Wed Dec 27 18:30:04 CET 2006


"Florian Schulze" <florian.schulze at gmx.net> wrote:

> On Fri, 22 Dec 2006 20:20:32 +0100, Alexander Limi  
><limi at plone.org> wrote:
> 
>> On Fri, 22 Dec 2006 07:04:18 -0800, Duncan Booth
>> <duncan.booth at suttoncourtenay.org.uk> wrote:
>>
>>>   - The javascript files used by Plone (and some of the other ones)
>>>     now run through jslint without warnings. This means they can be
>>>     compressed by programs which remove line endings in an unsafe
>>>     manner.
>>
>> Yay! Thanks, Duncan! This will make Kupu more lightweight for our
>> users  in
>> Plone 3.0. :)
> 
> Hi!
> 
> It will probably only help marginally. My packer (unlike Dean Edwards)
> is  clever enough to keep newlines where they are unsafe to remove
> ("safe"  compression is named like that for a reason :) ). Most of the
> time you add  a semicolon to allow safe removal of the newline, but
> that's the same  amount of bytes (one) except on DOS and Windows :)
> But it's generally good to have linted JavaScript, as it's more likely
>  that unlinted js fails to pack than linted.
> 
Full compression certainly broke kupu before I added the missing 
semicolons, but I think safe was indeed safe, so the difference probably 
only is marginal. I also found a couple of probably insignificant bugs 
during the linting. Mostly though I hope I've removed one source of 
possible user error.

If I could be bothered I would also go through and remove a lot of the 
extra semicolons (saving a few more bytes), but I don't want to remove them 
all as I really hate the idea that you may have to look back several 
hundred lines to work out whether or not a semicolon is actually required 
somewhere, so I'd rather that if in doubt just add a semicolon even when it 
isn't strictly required.

Is there a worthwhile benefit to inserting dollar signs in front of local 
variable names? There's no way I'm going through all the code to do that 
manually, but it might be possible to use the lint output (which can report 
on local variable usage) to automate the process somehow. e.g. building a 
list of all names which are only used as local variables and then doing 
global replaces on those names.

Of course the ideal might be to put a full javascript parser into 
ResourceRegistry's packer and then it could add and remove semicolons (and 
rename local variables) perfectly, but life is a bit too short for that.




More information about the kupu-dev mailing list