var page = require('webpage').create(),
    system = require('system'),
    outname, fs = require("fs");

String.prototype.endsWith = function(suffix) {
    return this.indexOf(suffix, this.length - suffix.length) !== -1;
};

if (system.args.length > 2) {
  outname=system.args[2];
} else {
  outname=system.args[1].replace('.html', '.png');
}
if (outname.endsWith(".pdf")) {
  page.viewportSize = { width: 1920 * 1.35, height: 1080 * 1.35};
} else {
  page.viewportSize = { width: 1920, height: 1080 };
}

page.open(system.args[1], function () {
    page.render(outname);
    phantom.exit();
});


@@ -536,24 +536,58 @@
 nction () %7B%0A
+  window.setTimeout(function () %7B%0A
     page.ren
@@ -620,13 +620,24 @@
 exit();%0A
+  %7D, 200);%0A
 %7D);%0A%0A

Add 200ms to load page