简体   繁体   English

包含jquery文件的正确顺序是什么?

[英]What is the correct sequence of including jquery files?

Today i wanted to add datepicker() to my page.So I downloaded jqueryui and added then in the sequence below. 今天我想在页面上添加datepicker(),因此我下载了jqueryui并按以下顺序添加。

<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/superfish.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/retina.min.js"></script>
<script src="assets/validate.js"></script>
<script src="js/jquery.placeholder.js"></script>
<script src="js/functions.js"></script>
<script src="js/wizard_func.js"></script>
<script src="check_radio/jquery.icheck.js"></script>
<script type="text/javascript" src="js/navi_artstyle.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="js/mapmarker.jquery.js"></script>
<script type="text/javascript" src="js/mapmarker_func.jquery.js"></script>

It didn't work. 没用 It took me whole day to figure out what is wrong. 我花了整整一天的时间才找出问题所在。 it was the SEQUENCE of js files included!!! 这是包含的js文件的序列!!! To work my code i had to include them like bellow.(" jquery.js " position had to change) 为了工作我的代码,我必须像波纹管一样包含它们。(“ jquery.js ”的位置必须更改)

    <script src="js/superfish.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/retina.min.js"></script>
    <script src="assets/validate.js"></script>
    <script src="js/jquery.placeholder.js"></script>
    <script src="js/functions.js"></script>
    <script src="js/wizard_func.js"></script>
    <script src="check_radio/jquery.icheck.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/navi_artstyle.js"></script>
    <script type="text/javascript" src="js/jquery-ui.js"></script>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="js/mapmarker.jquery.js"></script>
    <script type="text/javascript" src="js/mapmarker_func.jquery.js"></script>

Can some one explain this please. 有人可以解释一下。 Please give me a Source so I wont make this mistake again. 请给我一个消息来源,这样我就不会再犯这个错误了。

  1. Normal jQuery (core) 普通jQuery(核心)
  2. jQuery migrate if you have jQuery迁移(如果有)
  3. jQuery UI jQuery UI
  4. jQuery mobile jQuery Mobile
  5. Scripts that need jQuery / scripts that are jQuery plugins 需要jQuery的脚本/ jQuery插件的脚本
  6. Other scripts like bootstrap 其他脚本,如引导程序
  7. You own scripts depending which is needed first 您拥有脚本,具体取决于首先需要的脚本

首先,您必须包含普通的jQuery库。此后,您必须包含其他jquery库,例如jquery ui和jquery mobile,最后必须包含自己的javascript文件。

As mentioned in comments you have to mention the scripts in the order you use that. 如评论中所述,您必须按使用顺序提及脚本。

Simply anything used Jquery will goes after jQuery, anything that depends on jQuery UI goes after jQuery UI etc. 简而言之,所有使用过的Jquery都会在jQuery之后,而所有依赖jQuery UI的都会在jQuery UI之后。

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

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