EyeonTips:Script/General Concepts/Script Libraries and Event Scripting
From VFXPedia
Composition Scriptlibs
As mentioned in the beginning, a .scriptlib file in your main Scripts: directory will be executed every time Fusion is started and when a comp is opened. In addition to this, you can also place a .scriptlib file in your Scripts:\Comp folder (where comp scripts are located). In this case, the scriptlib will only be executed every time a comp is opened (or a new one is created). (thanks to Isaac for mentioning this on the mailing list)
If you want a scriptlib to run only once when Fusion is started, you can check for the presence of the composition variable that's available to comp and tool scripts as well:
if composition == nil then -- no comp: Fusion is being started else -- a comp is present end