I have a custom module which is having dependency on contributed module.
How can i make sure that contributed module will be loaded before custom module ?
You could update the module weight so that it is lower than that of the contrib module meaning it would get loaded first.
In your custom modules .info file add the following line.
dependencies[] = contrib-module-name
For more info refer this.
And add the module_exists condition in your code.
$module = 'required module name';
if(module_exists($module)){
Your Code;
}
Hope this will help you.
If you need to load a specific file or function, you may include the related file using module_load_include.