troubles with facebook javascript #11156

erikgardman opened this Issue Mar 21, 2013 · 8 comments

5 participants



I am trying to open the page of facebook group and getting a lot of javascript errors randomiously.

I.e i'm tried first time and all is OK - page is loaded without errors, my evaluated javascript on page work success

Repeat opening and all is OK too.

Repeat third and got in console:

TypeError: 'undefined' is not a function (evaluating 'l.bind(this,s)') in k
ReferenceError: Can't find variable: Bootloader
Error: Requiring unknown module "ServerJS" in j
ReferenceError: Can't find variable: $
ReferenceError: Can't find variable: Bootloader
Error: Requiring unknown module "InitialJSLoader" in j
ReferenceError: Can't find variable: Bootloader, function (status) { }); -- status can be a 'fail' or success..

What can it be?
It seems as not all javascript files is loaded.
How to load it all with phantomjs?



"When the content is GZIPed, then PhantomJS will sometimes throw an "$ is undefined" exception but sometimes work correctly. When the content is not GZIPed, then PhantomJS will work correctly."

I've tried to add customHeaders, but no result:

var page = require('webpage').create();

page.customHeaders = {
'Accept-Encoding': 'identity',

When loading is success and js is workng, we can see that this resorses is loaded:

When loading is failed - phantomjs load only first 4-5 resources from this list.

Updated: Description: Host not found


So, problem solved.

If custom user-agent is set (over page.settings.userAgent or page.customHeaders, no difference) -- facebook resources loaded partially 90% times.

When i remove setting up custom user-agent - all start work correctly 100% times.
What the hell =\

@ariya ariya closed this Mar 22, 2013

Why is this closed? This still affects 1.9


I thought it was just user agent problem. Reopening.

Also, any further details will be appreciated. Otherwise, it's hard to understand what the problem is. Refer to the Troubleshooting section on the wiki to provide more detailed info.

@ariya ariya reopened this Mar 25, 2013

Which version of PhantomJS are you using? Tip: run 'phantomjs --version'.
1.9.0 (development)

What steps will reproduce the problem?

  1. add handler

page.onResourceReceived = function (request) {
console.log('[res]<-- #' + + ' ' + request.url);

  1. set user-agent:

var page = require('webpage').create();

// first method:
page.customHeaders = {
'User-Agent': 'Mozilla/5.0 (X11; Linux i686; rv:18.0) Gecko/20100101 Firefox/18.0', -- все идет по пизде

// second method:
page.settings.userAgent = "Mozilla/5.0 (Windows NT 6.1; ru-ru) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17";

  1. open (

What is the expected output? What do you see instead?

70% times onResourceReceived show only 4-5 first resouces of the page => all javascript on facebook page does not work and generating a lot of error messages.
In other case, phantomjs load 100% resources (20-30 elements) and all works fine.

Which operating system are you using?
Linux arch, 32 bit
Linux my_host 3.7.8-1-ARCH #1 SMP PREEMPT Fri Feb 15 04:14:33 EET 2013 i686 GNU/Linux

Did you use binary PhantomJS or did you compile it from source?
Compiled from source

Please provide any additional information below.
Without setting user-agent all works correctly always.


It's Facebook's optimizations. Facebook use the user-agent to determine browser and its possibilities.
If you set any other user-agent (IE7/8, ...), you will see, that all work fine.
We can't fix it.


I've actually seen the same issue as quoted from #10930 related to compression (compressed via IIS web server) when opening pages in Chrome and Safari (on Windows 7 64-bit). As such, I would guess it's a combination of a WebKit bug/deficiency plus whatever "smart" UA-sniffed compression algorithm is being used thinking that WebKit is more capable than it actually is.

I had to disable IIS compression and handle it myself to resolve my issue.


We need to establish a good practice in reporting issues like this. We simply can not keep every single issue "it does not work with FooBar site". There are millions web sites out there and sometimes the problem is with the upstream library we use (QtWebKit) and not PhantomJS own code.

Unless there is a proper reduced test case, not much we can do in that regard. Perhaps this is a good time to kickstart such a discussion in the mailing-list.

@yuxel yuxel referenced this issue in sonsuzdongu/get-http-resources.js Apr 19, 2013

Facebook'ta çeşitli uyarılar veriyor #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment