Greg Owens

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromGreg Owens
ToMe
SubjectJSTidy - retain inline comments?
Date2 June 2009 15:01
Tarquin

Two items:

I use JSTidy fairly frequently, alongside [author]'s [brand]. I
would **definitely** use JSTidy more frequently were it to simply give the
option to allow me retain the inline comments I placed in my code during
development. Is this an enhancement you are likely to offer in the future?
Again - alluding to [brand] - the ability to specify options (much like
[URL] does for SQL formatting) would change JSTidy from
an occasionally-useful tool to one I would likely use on a daily basis.

Perhaps unrelated: I'd be interested in any utility that would allow me to
better organise my JS files, such that functions appear either
alphabeticised by name or even by strict order that they need to be declared
in (e.g. if functionA calls functionB, then functionB should be declared
prior to functionA. Perhaps a tool already exists but I haven't found it.
The consequence is that my JS files are often a bit of a mess with functions
appearing wherever they were born (be it the result of refactoring,
inspiration or even planning!).


Thanks for reading, hope to hear back from you.

Best wishes

Greg
FromMe
ToGreg Owens
SubjectRe: JSTidy - retain inline comments?
Date4 June 2009 08:04
Greg,

It's rare to find any comments in code that is so messy as to need
tidying before it can be understood. JSTidy originated when trying to
debug massive library scripts that have had all comments and whitespace
removed in a futile attempt to reduce download size.

> option to allow me retain the inline comments I placed in my code during
> development. Is this an enhancement you are likely to offer in the future?

JSTidy simply uses whatever the browser decompiles the code to. Browsers
that do decompilation do not retain comments, therefore JSTidy also cannot.

The only other option would be to write a complete JavaScript parser
that spits out the tokens in a custom desirable format. This is far
beyond the scope of JSTidy, though I would love it if someone were to
take the time to do it. Such a project could also move function
declarations to the top of the current scope (Opera 8 often does this
anyway), and sort them as desired.

JSTidy was created basically because there was no such program, and it
offered a very simple way to produce something hopefully tidy enough to
allow debugging. It's far from perfect (and that's not something I can
change, given the way it works, which is at the mercy of whichever
browser you use it with), but it usually helps to get the job done.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromGreg Owens
ToMe
SubjectRe: JSTidy - retain inline comments?
Date4 June 2009 09:32
Hi Tarquin

I appreciate you taking the time out to reply to my query. I guess my use of
JSTidy is partially to standardise my formatting when moving from dev to
prod, rather than the use case you cited. I hadn't realised that it was
acheived using intrinsic browser decompilation - this helps to understand
why it works as it does (and indeed why IE is not supported!) and also why
extending its functionality would be a rewrite.

JSTidy will remain a useful tool to me, despite what are unavoidable
limitations - thank you for making it available to the likes of me!

Best wishes

Greg
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.