You just test with `featurep`:

<!-- language: lang-lisp -->

    (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:

<!-- language: lang-lisp -->

    (when (require 'projectile nil t)
      (do-some-stuff-that-needs-projectile)