views:

98

answers:

4

Is there a limit of how many js file I can include () in facebook? I include 5 files. no problem.. the 6th one not loaded. Then I have to put the code in the 6th one into the 5th file. then works. so, is it 5 files in max?

BY THE WAY, I'm developing the apps now, not in production. so it is not in the stage of compressing JS / minizing it. :)

so it is kinda annoying to got missing js files or files not loaded..etc

so, what is the limit from FB? what is the file size limit? I know that the JSON request call back data limit is 5000.. but not sure about the js include.

+1  A: 

From a user perspective, you should be loading as few as possible, not trying to see how many you can shove in there. More independent files means more HTTP Requests for the client which means a slower page load.

Also, I'd minify your script before pushing into production, less bytes means a faster page as well.

Nick Craver
Agreed, doing a join+minify of scripts for an application is probably a good idea all around.
Tracker1
I know. But now, I'm just doing development. Not in production stage. It is kinda annoying when files are not loaded.
Murvinlai
+1  A: 

I have 29 scripts loaded on development environment and just recently have I started seeing issues with the files not being loaded and stuff.

But if you are writing a iframe based app then I cannot reason out why/how facebook will limit the number of JS files loaded. Check out network latency though because, with a very slow connection facebook might try reloading the whole page and in the process refetching all of your static assets unless they are cacheable.

Browser caches can also be a factor. Firefox 3.6 does very aggressive caching and frankly speaking it has more glitches than any thing else. Hence check to see if your incomplete js files are already cached by the browser.

Mukund
In an iframe app, Facebook *can't* control anything, right? It's your own personal frame.
Matchu
it is FBML app. :)
Murvinlai
+2  A: 

Yes, Facebook should not do anything within an IFrame app. Okay even for an FBML app, there are some things that might cause the issue:

  1. script tags must be ended by a separate closing tag, they do not work like link tags.

  2. Some browsers for instance IE limit the total number of link tags that are included on a page (IE link tag limit seems to be 31). I am not really sure if there is some hard limit like that on the number of script tags too, but I would check that too. Searching on the web, did not yield anything.

  3. While javascript files are loaded and run, every other parallel file download from that domain is disabled, so make sure that some javascript file that you have included is not blocking others from being downloaded.

  4. Also only two-six files are downloaded in parallel from a domain, and as an extra precaution only one javascript file is downloaded at any given time. Hence make sure you do not have an excessively big js file/ unreachable js file that is hogging the pipeline.

  5. To circumvent point 5 you can dynamically script js file downloads, because the hard limit of 2-6 parallel downloads only pertains to HTML scripted files. So using javascript to load additional files will increase the number of parallel downloads that can happen.

From my experience I just concatenated all the 30 or odd files into 3 files and included these 3 files in production environments and continued to use the individual files for development.

It seemed to me that Facebook was timing out somehow and trying to reload the page in the earlier case, when the network latency to download some of the js files was high (cannot prove this theory though).

Mukund
+1  A: 

They allow 1000 unique scripts that you can include in your app - http://wiki.developers.facebook.com/index.php/Include_files

santhakr