Now I need to add the jQuery lightGallery to pages using this field formatter and call the library when the page is ready. I am confused about how I am supposed to do this, though.
I defined the library in the module containing my field formatter, but I'm not sure how I attach it only on sites that contain the field.
The documentation of the library uses the jQuery
$(document).ready function to call the libary, how would that work inside a Drupal module?