Use setImmediate to isolate client and loader code