I’ve received quite a few emails recently asking me where the code is for jParser.
I’ve had to disappoint so far, because it’s not currently available for download. My web analytics also tells me that a lot of people are finding this blog by Googling “php javascript parser“. There’s clearly a need out there, so I’d better do something about it.
I know why I want a JavaScript parser, but what kind of things might you need it for? What API features/functions would you like to see? Please post a comment and let me know. Watch this space for a release, and in the mean time here’s some food for thought …
Do you really need a full parser?
Perhaps all you really need is a tokenizer. Suppose you want to highlight JavaScript code – you don’t need a full parser; all you need to do is break the source code into meaningful chunks (strings, numbers etc..) . How these chunks work together to form syntax is not an issue. I envisage releasing a lighter-weight library containing just the tokenizer (jTokenizer I guess). This will work exactly the same as the PHP tokenizer functions.
Minifying, or obfuscating JavaScript
If you’re after a minifier, there are lighter-weight PHP options available. However, I’ve released a command line version of my JavaScript minifier and obfuscator which is quite handy. It’s more powerful than most JavaScript minifiers, because it supports automatic semicolon insertion. This means it can reduce any code to a single line.