Mobile version of this pageSpaceinvaders with real people
Next:
slim in ruby
Related blogs
XHTML, HTML and CSS compressorOptimized stylesheets
Optimize Plone.org with slimmer.py
Smooth anchor scrolling Javascript
Private functions in Javascript?
Slimmer with --hardcore
Fastest way to uniqify a list in Python
Gzip and Slimmer optimization anecdote
slim in ruby
Related by category
slim, a new free web service for white space optimisation
xml rpc, web service, javascript code, slimmer, slim, optimisation, whitespace
25th of July 2006
If you have some code that you need to optimise, like some Javascript code that is well commented but costs too many bytes of download for your users then you might want to use my slimmer web service. I'll let a Python example speak for itself:
>>> s=xmlrpclib.Server('http://www.peterbe.com/')
>>> css='h1 { font-family: Arial, Verdana; }'
>>> s.slim(css)
'h1{font-family:Arial,Verdana}'
Basically, on www.peterbe.com there's a XML-RPC web service called slim which takes two parameters: code and syntax. The second parameter accepts either css, js, html or xhtml and if you don't bother passing anything (like in the example above), the program will do a qualified guess. Here are some more examples:
... if (variable1 == variable2) {
... return true;
... } else {
... return false;
... }
... }'''
>>> s.slim(js, 'js')
'function (_0,_1) {if(_0==_1){return true;}else{return false;}}'
>>> html='''<a href="a" title=" test ">
... <strong> TEST </strong> </a>
... <!-- some comment -->
... '''
>>> s.slim(html, 'html')
'<a href="a" title=" test "><strong> TEST </strong></a>'
If you think XML-RPC is too fancy, you can use HTTP POST instead. To test it create a form in HTML like this:
<textarea name="code"></textarea>
<input name="syntax" value="html">
<input type="submit">
</form>
And when you submit that form it'll return the code provided with all excess whitespace removed. Example here







Save this page in del.icio.us
about css parameters
http://css-lessons.ucoz.com/css-parameters.htm