View source on the widget example app should show you. Here is the specific call. This causes the function to be attached to the body load event.
gadgets.util.registerOnLoadHandler(function(){
window.friendPicker = new MyOpenSpace.Widgets.FriendPicker(
{
element: "pickerDiv01",
buildSelectedUI: true
}); );
The only constraint is that the div element referenced in the constructor (here "pickerDiv01") should already be added to the DOM. The short answer is put this call at the bottom of your code. IE has shown some errors with this approach that usually go away if you reload the page (IE gets the Widget js code in its cache). When we get a solid fix to this the sample app will be updated to reflect it.