Adding code before any page loads

The correct way to do this would be to wrap your custom functionality in a function and hook it to init.

tech