This may seem like an unusual request, but does anyone have T-SQL (MSSQL2008) code to “minify” javascript code?
I have a MVC site that uses a series of stored procs to generate the contents of a *.js file, and preferably after the SPs built the javascript, it could use a UDF/SP to ‘minify’ it.
I thought about creating a second SP set that would contain the minified version, but that would be a maintainance nightmare (doubling the current 10 SP’s that build the javascript code).
I didn’t know if the logic used to minify was simple enough that an SP/UDF could do it, and if lucky someone had already written it and was willing to share 🙂
Thanks in advance!
I don’t think that minifying javascript using a SP is a good idea. You will end up with something really complex I guess. The simplest minifier that I know is jsmin and it still 300 lines of C.
Another approach could be to user a minifying proxy as a web server. I guess that it’s quite fast (less than 20 lines of code) to come up with something using nodejs and uglifyjs.