简体   繁体   English

如何查明和解决由多个外部Javascript和CSS引起的冲突?

[英]How to pinpoint and resolve conflict caused by multiple external Javascript and CSS?

While building a page, I have imported multiple (more than 10) external CSS and Javascript, including but not limited to timerangepicker, bootstrap and tabber. 构建页面时,我导入了多个(超过10个)外部CSS和Javascript,包括但不限于timerangepicker,bootstrap和tabber。

The problem is, there seems to be some conflict when all of them load together, as they cause my UI to be totally messed up (some elements would show up in the wrong places, some features such as timerangepicker won't work). 问题是,当它们全部一起加载时似乎存在一些冲突,因为它们导致我的UI完全混乱(某些元素会显示在错误的位置,某些功能(例如timerangepicker)将无法工作)。

I'm pretty sure the conflict is caused by all these files loading together, because some UI will become normal again when I disable some of the external files. 我非常确定冲突是由所有这些文件一起加载引起的,因为当我禁用某些外部文件时,某些用户界面将再次恢复正常。 These are the external files: 这些是外部文件:

    <script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap/3/css/bootstrap.css">
    <script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
    <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />

    <link rel="stylesheet" type="text/css" href="<?php echo APP_WEBSITE;?>/css/style.css">
    <link href="<?php echo APP_WEBSITE;?>/css/tabber.css" rel="stylesheet" type="text/css" />
    <link href="<?php echo APP_WEBSITE;?>/css/styles-pop.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<?php echo WEBSITE;?>/js/tabs_slides.js"></script>
    <script type="text/javascript" src="<?php echo WEBSITE;?>/js/tabber.js"></script>
    <script src="<?php echo WEBSITE; ?>/js/jquery-1.11.0.min.js"></script>
    <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../templates/layout/css/bootstrap.css">
    <link rel='stylesheet' href="<?php echo APP_WEBSITE;?>/css/browsebootstrap.css">
    <link rel="stylesheet" type="text/css" href="<?php echo APP_WEBSITE; ?>/css/checkbox.css">
    <link rel="stylesheet" type="text/css" href="<?php echo APP_WEBSITE;?>/css/ver02/search_payment.css">
    <script src="<?php echo WEBSITE; ?>/js/browse.js"></script>
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
    <script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
    <script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
    <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
    <link href="css/default.css" rel="stylesheet" type="text/css" />
    <link href="css/form.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/scrollbar.css">
    <link href="css/topmenu.css" rel="stylesheet" type="text/css" />
    <link href="css/search.css" rel="stylesheet" type="text/css" />
    <link href="css/font-awesome.css" rel="stylesheet" type="text/css" />
    <link href="css/font-awesome-animation.min.css" rel="stylesheet" type="text/css" />

I know there are some redundancies, but strangely, some of the features will only work if I put it this way. 我知道有一些冗余,但是奇怪的是,某些功能只有在我这样说的情况下才能起作用。

My question is, how do I pinpoint exactly which files are in conflict with which files? 我的问题是,如何准确确定哪些文件与哪些文件冲突? There are just too many of them. 他们太多了。 And how can I avoid the conflict? 我该如何避免冲突?

Thanks and cheers. 谢谢和欢呼。

First move is to strip of the duplicate file references. 第一步是删除重复的文件引用。 For example you have 4 referenced jquery files of different vesions. 例如,您有4个引用的不同版本的jquery文件。 Use just one. 只使用一个。

<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap/3/css/bootstrap.css">
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />

<link rel="stylesheet" type="text/css" href="<?php echo APP_WEBSITE;?>/css/style.css">
<link href="<?php echo APP_WEBSITE;?>/css/tabber.css" rel="stylesheet" type="text/css" />
<link href="<?php echo APP_WEBSITE;?>/css/styles-pop.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo WEBSITE;?>/js/tabs_slides.js"></script>
<script type="text/javascript" src="<?php echo WEBSITE;?>/js/tabber.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="<?php echo APP_WEBSITE; ?>/css/checkbox.css">
<link rel="stylesheet" type="text/css" href="<?php echo APP_WEBSITE;?>/css/ver02/search_payment.css">
<script src="<?php echo WEBSITE; ?>/js/browse.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
<link href="css/default.css" rel="stylesheet" type="text/css" />
<link href="css/form.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/scrollbar.css">
<link href="css/topmenu.css" rel="stylesheet" type="text/css" />
<link href="css/search.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome.css" rel="stylesheet" type="text/css" />
<link href="css/font-awesome-animation.min.css" rel="stylesheet" type="text/css" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM