Yes.
The solution to that is to create an event handler for "VARIABLES_LOADED" (or similar event), and run the code then.
Code:
local f = CreateFrame("frame")
function f.event()
--your code here
end
f:SetScript("OnEvent", f.event)
f:RegisterEvent("VARIABLES_LOADED")