I was working on a project where I needed to get the current web's ID or URL (sometype of unique identifier) in javascript without making an service call (executeQueryAsync). I didn't seem to be able to find a method that would return this information before a load and executeQueryAsync. Through IE dev tools I was able to find the value of the url and the ID in the object but it was stored in some strang variables ($0_0.$1P_0 and $0_0.$r_0[0].$M_1). Does anyone know of a supported way to get this information before the web object is loaded through the executeQueryAsync. Here's some code to refer to, I basically don't want to perform the extra service call for this website if I've already done it once in this session for this website.
function DoStuff() {
if ( GetCookie("MyStuff"+SP.ClientContext.get_current().get_web().$0_0.$1P_0) ) return;
var listTitle = "Stuff";
var context = new SP.ClientContext.get_current();
this.web = context.get_web();
this.user = web.get_currentUser();
this.list = web.get_lists().getByTitle(listTitle);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View><Query><Where><Eq><FieldRef Name='Author' /><Value Type='Integer'><UserID /></Value></Eq></Where></Query><RowLimit>1</RowLimit></View>");
this.listItems = list.getItems(camlQuery);
context.load(web);
context.load(user);
context.load(list);
context.load(listItems);
context.executeQueryAsync(StuffSucceeded, StuffFailed);
}
function StuffSucceeded(sender, args) {
DoSomeStuff();
SetCookie("MyStuff" + SP.ClientContext.get_current().get_web().$0_0.$1P_0, 'True', '/');
}
function StuffFailed(sender, args) {}
ExecuteOrDelayUntilScriptLoaded(DoStuff, "sp.js");