Use a standard script loader technique such as seen here: http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/ (as per Steve Souders legendary books on performance the link provided basically uses exactly the same code and is a good starting point).
Or if you need a little extra try something like LABjs by @getify Sent from my iPhone On 20 Aug 2011, at 14:44, Philip Schweiger <[email protected]> wrote: > I'm using jQuery.getScript(), and in the callback function I resolve a > jQuery Deferred object. All actions using my script, then have to be > wrapped inside the "done" callback of the Deferred object. > > I don't think there's any way to avoid that overall mechanism, since > the FB library must be loaded first, and there needs to be some > indication that it has finished loading. Some sort of "ready" function > will always be necessary. > > Ideally, though, I would be doing this in pure JavaScript, so that a > developer can use any additional library (eg Dojo, Prototype), or no > library at all, rather than being forced to load jQuery. > > On Aug 20, 2:49 am, Mark McDonnell <[email protected]> wrote: >> What particular jquery fn are you using to load the fb library? Im assuming >> the fb script is bring requested via jsonp or some other cross domain >> variation as Ajax loading a script from another domain isn't possible >> otherwise. >> >> Sent from my iPhone >> >> On 19 Aug 2011, at 02:26, Philip Schweiger <[email protected]> wrote: >> >> >> >> >> >> >> >>> Hi, >> >>> I recently posted a small library on github that is a wrapper around >>> the Facebook JavaScript SDK. I'm calling it FSW, for Facebook >>> JavaScript Wrapper. >> >>> https://github.com/anyonecancode/FSW >> >>> It's an attempt to address some of the more painful aspects I've found >>> in developing for Facebook - contradictory documentation, inconsistent >>> interfaces, and lack of versioning. >> >>> This is an early release, so it only wraps around the FB features I've >>> had to use frequently, but I hope to continue developing FSW and >>> adding more features. If anyone has time and inclination, especially >>> anyone who's had to work with the FB SDK, I'd appreciate feedback. I'm >>> especially looking for feedback around the following: >> >>> - ease of use. My main impetus for the wrapper is to make it easier to >>> interact with Facebook, so meeting this is the most basic pass/fail >>> point. >> >>> - quality of the code. I'm using the module pattern, but I would >>> probably classify myself only as an intermediate JS developer, so if >>> I'm missing out on some obvious best practices, I'd like to hear it. >> >>> - documentation tips. I only recently discovered jsdoc-toolkit, which >>> I'm using to generate the documentation. >> >>> - Reducing dependencies. The wrapper requires jQuery (tested on >>> 1.6.2); if possible I'd like to eliminate that dependency. Doing DOM >>> selection without jQuery wouldn't be so much of a problem, but I am >>> also using jQuery to load the official Facebook SDK and fire a ready >>> event when that's loaded; I'd love to learn about alternatives. I did >>> try an earlier version of this using require.js, which is nice, but >>> ideally I wouldn't have any dependencies on outside libraries (beyond >>> the Facebook library, of course). >> >>> Thanks! >> >>> Philip Schweiger >> >>> -- >>> To view archived discussions from the original JSMentors Mailman list: >>> http://www.mail-archive.com/[email protected]/ >> >>> To search via a non-Google archive, visit >>> here:http://www.mail-archive.com/[email protected]/ >> >>> To unsubscribe from this group, send email to >>> [email protected] > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
