首页 \ 问答 \ 多个html页面一个js文件?(mulitple html pages one js file?)

多个html页面一个js文件?(mulitple html pages one js file?)

我的网站上有多个html页面和滑块。

我正在使用Bxslider,一些页面也有Owl Carousel,但我不想让多个.js文件在每个页面上调用不同的滑块。

我可以只制作一个js文件,并在所有页面上使用上面的代码。 像这样,在一个.js文件中调用所有滑块

$(document).ready(function(){
  $('.bxslider').bxSlider();
  $("#owl-example").owlCarousel();
});

我不想在每个不需要它的页面中包含插件(owl-carousel和bxslider)js文件。

在没有滑块的页面上调用滑块会影响性能吗?

谢谢 !


My website has multiple html pages and sliders in them.

I'm using Bxslider and some pages also have Owl Carousel, but i dont want to have multiple .js file to call different sliders on each page.

Can i make just one js file and use the above code for example on all of the pages. Like this, calling all sliders in one .js file

$(document).ready(function(){
  $('.bxslider').bxSlider();
  $("#owl-example").owlCarousel();
});

I don't want to include both plugins(owl-carousel and bxslider) js file in every pages that don't need it.

Does it effects performance to call the slider on pages that dont have that slider ?

Thanks !


原文:
更新时间:2022-03-18 21:03

最满意答案

好吧,在对这个问题进行了大量搜索之后,我终于找到了答案。

我使用的是Gradle 2.14,所以我需要改变

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

有很多不同之处, 在这里我们可以看到更多细节。


OK, after a lot searchings about this issue, I finally worked it out.

I'm using Gradle 2.14, so I need to change

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

to

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

There are a lot of differences, and here we can see more details.

相关问答

更多
  • 确保你已经下载了最新的ADT,SDK,平台和构建工具。 然后将其添加到您的Gradle构建中。 android { buildToolsVersion "17.0" compileSdkVersion 15 } 贷给adt邮件组。 注意:如图所示,将“ 17.0左右”放在一起非常重要 - 否则不起作用 Make sure that you've downloaded the latest ADT, SDK, Platform and Build tools. Then add this ...
  • compileSdkVersion是您编译的API的API版本。 buildToolsVersion是要使用的编译器(aapt,dx,renderscript编译器等)的版本。 对于每个API级别(从18开始),有一个匹配的.0.0版本。 在2014年10月,我们发布了API 20和构建工具20.0.0。 在Android版本之间,我们将发布编译器的更新,因此我们将发布版本.0.1,.0.2等。因为我们不想在您下面静默更新这些版本,所以您需要转到新版本,当你方便的时候。 您可以使用比您的compileSdk ...
  • 至少,使用throw new IllegalStateException(e); 首先要保留有关导致异常的原因的信息。 我个人会确保在我需要使用它们之前确保所有必需的变量(mOpenHelper等)都已正确初始化后,NPE不会发生。 At the minimum, use throw new IllegalStateException(e); to keep the information about what caused the exception in the first place. I would ...
  • 看看你的build.gradle (Module:)文件。 该文件中应该有一个buildToolsVersion行。 确保你和其他人安装了该版本的构建工具。 还要确保构建工具的版本仍可从SDK管理器获得。 在处理朋友的项目时,我遇到了这个问题。 他正在使用我无法再使用的构建工具版本。 我认为这是因为事情被更新和替换。 我们通过安装最新版本的构建工具来解决这个问题。 当我升级Android Studios并且版本工具的版本不再可用时,我也遇到了这个问题。 对于compileSdkVersi ...
  • 好吧,出于好奇,我回去再试一次。 我要安装它并多次打开它,看它是否有效。 令我惊讶的是,它每次都有效!!!!! 我一直在玩它几分钟卸载并重新安装它和它的工作。 这很奇怪,因为我知道我之前在Honeycomb上测试了它并且它在过去有效。 所以我不知道这可能只是模拟器中的一个小故障,但现在看起来还不错。 我只是希望我有一个具有此配置的设备来测试它。 因此,如果任何人对MIGHT导致这种情况有任何想法或建议,我愿意考虑每一个,以确保。 Ok well just out of curiosity I went ba ...
  • 降级构建工具不是一项大任务,您只需从Android SDK中删除版本24文件夹即可。 参考我的截图。 它来自MacOS,但所有操作系统的结构仍然相同。 您可以看到build-tools文件夹中没有24个文件夹,因此请删除版本24的所有内容,直到我们有一个Ti SDK来支持它。 Not a big task to downgrade build tools, all you need is just to delete version 24 folder from Android SDK. Refer my ...
  • 看起来您使用的是实验性gradle插件版本。 稳定版本2.0.0和实验版本在build.gradle文件中的符号有一些差异。 例如, android块需要在model块之外。 并且一些属性规范略有不同。 看看Experimental Gradle Plugin用户指南 ,特别是build.gradle示例文件中红色突出显示的部分。 我也不确定,但非实验版仍然没有完整的NDK支持。 虽然看起来实验版0.6确实支持NDK和Instant Run,但您可以使用0.6版而不是2.0版。 Looks like you ...
  • 好问题。 是! 这是可能的。 我的回答大量使用此代码段: https : //github.com/aayvazyan-tgm/autodetect_android_sdk_and_buildTools/blob/master/sdktools.gradle apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion getBuildVersionFromRange("23 ...
  • 好吧,在对这个问题进行了大量搜索之后,我终于找到了答案。 我使用的是Gradle 2.14,所以我需要改变 classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' 至 classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' 有很多不同之处, 在这里我们可以看到更多细节。 OK, after a lot searchings about this issu ...
  • 文件说明: sendRedirect抛出:IllegalStateException - 如果此响应已提交 由于禁用maxPostSize并不能解决问题(根据OP注释),似乎在较早的时候响应正在提交。 您可以通过检查isCommited标志来验证这一点。 The Documentation states: sendRedirect Throws: IllegalStateException - if this response has already been committed Since disabli ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)