You just test with featurep
:
(require 'projectile nil t)
(when (featurep 'projectile)
(do-some-stuff-that-needs-projectile))
(require 'projectile nil t)
(when (featurep 'projectile)
(do-some-stuff-that-needs-projectile))
or you use that the require
returns nil if it is not possible to load:
(when (require 'projectile nil t)
(do-some-stuff-that-needs-projectile)
(when (require 'projectile nil t)
(do-some-stuff-that-needs-projectile)