mincss now support PhantomJS

02 February 2013   3 comments   Python

Powered by Fusion×

Remember mincss from a couple of days ago? Now it supports downloading the HTML, to analyze, using PhantomJS. That's pretty exciting because PhantomJS actually supports Javascript. It's a headless (a web browser without a graphical user interface) Webkit engine. What mincss does is that invokes a simple script like this:

var page = require('webpage').create();
page.open(phantom.args[0], function () {
  console.log(page.content);
  phantom.exit();
});

which will allow any window.onload events to fire which might create more DOM nodes. So, like in this example it'll spit out HTML that contains a <p class="bar"> tag which you otherwise wouldn't get with Python's urllib.urlopen().

The feature was just added (version 0.6.0) and I wouldn't be surprised if there are dragons there because I haven't tried it on a lot of sites. And at the time of writing, I was not able to compile it on my Ubuntu 64bit server so I haven't put it into production yet.

Anyway, with this you can hopefully sprinkle less of those /* no mincss */ comments into you CSS.

Comments

ëRiC
He Peter! Nice to see you progressing about this! I really like the idea of having a computed view onto your CSS rather than just the eye :]

after some days of your first post read an article on this already:
http://www.csstrashman.com

dunno if thats news to you.
ëRiC
Peter Bengtsson
Looks promising, but...
http://cl.ly/MfAk
ëRiC
AAahhhh haahaaaa ... ehmm *harrump* I actually didn't test it!
But this should be embarassing for them! Your site is far from compicated, isn't it?
Thank you for posting a comment

Your email will never ever be published


Related posts

Previous:
mincss in action - sample report from the wild 22 January 2013
Next:
mincss version 0.8 is much much faster 27 February 2013
Related by keywords:
mincss "Clears the junk out of your CSS" 21 January 2013
What's the average number of domains a website depends on? 24 February 2014
mincss in action - sample report from the wild 22 January 2013
This site is now 100% inline CSS and no bytes are wasted 05 March 2013
mincss version 0.8 is much much faster 27 February 2013
window.onload from before 07 June 2005