检查jQuery插件是否已经初始化的函数 [英] Function to check if jquery plugins are already initialized
问题描述
我想检查jquery插件是否已经初始化/包含(防止重复加载资源),否则,我想通过CDN或本地来源添加插件.
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?
更新:
我目前正在使用drupal构建自定义模板.在该模板中,我使用了光滑的滑块来滚动浏览内容库中的图片.我也想为幻灯片放映使用自定义模块,该幻灯片也使用光滑的滑块(模块中集成了js,css).所以现在我想检查slideshow模块的滑动滑块是否已经初始化,如果不是,我想通过CDN加载滑动滑块js.
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.
更新2: 通过使用php和drupal核心功能解决了该问题.我还找到了Modernizr.js加载功能->异步加载的解决方案.
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
}
这篇关于检查jQuery插件是否已经初始化的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!