i want to check if jquery plugins are already initialized / included (prevent dublicate resource loading) and if not i want to add the plugin by CDN or by a local source.
Anyone can help me with that Problem?
Update:
I'm currently building a custom template in drupal. In that template i'm using a slick slider for scrolling through pictures in a content gallery. I also want to use a custom module for a slideshow, which uses the slick slider too (js, css integrated in the module). So now i want to check if the slick slider of the slideshow module is already initialized, if not i want to load the slick slider js via cdn.
Hope that helps for understanding my problem.
Update 2: Resolved the problem by using php and drupal core functions. I also found a solution with the modernizr.js load function -> asynchronous loading.
You can check and detect the plugin using this
if(jQuery().pluginName) {
//run plugin
}
You can try this:
if (!jQuery.fn.plugin) {
jQuery.getScript('http://url/to/the/script');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With