以特定顺序包括jqPlot文件 [英] Including jqPlot files in particular order

查看:111
本文介绍了以特定顺序包括jqPlot文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在头文件中必须包含jQPlot的特定顺序吗?目前,我正在使用jQMobile,但由于某种原因,我的jqPlot BarRenderer.js无法被识别...

Is there a particular order that jQPlot has to be included in a header? Currently I'm using jQMobile, but for some reason my jqPlot BarRenderer.js isn't being recognized...

<head>  
    <!-- CSS -->
  <link rel="stylesheet" href="./signup.css">
  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
  <link rel="stylesheet" type="text/css" href="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog.min.css" /> 

  <!-- Modernizer -->
  <script type="text/javascript" src="./modernizr.custom.56582.js"></script>
  <!-- jquery -->
  <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>

   <!-- simpleDiaglo2 -->
  <script src="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog2.js"></script>
  <script type="text/javascript" src="http://dev.jtsage.com/cdn/simpledialog/latest/jquery.mobile.simpledialog2.min.js"></script>
  <!-- Bar Chart -->
  <script class="include" language="javascript" type="text/javascript" 
        src="./jquery-jqPlot/jquery.jqplot.js"></script>
 <script class="include" language="javascript" type="text/javascript" src="./jquery-jqPlot/plugins/jqplot.barRenderer.min.js"></script>

</head>

推荐答案

示例加载顺序可能是jQuery,jqplot,主渲染器,轴渲染器,然后是点标签.顺序取决于项目依赖性.

An example loading order might be jQuery, jqplot, main renderer(s), axis renderer, then point labels. Order is dependent on project dependencies.

您包括来自CDN的JS,这很好.但是在您的示例中,页面的<head>中包含了JavaScript.您应该在</body>标记上方添加JS,以加快页面加载时间. CSS应该包含在<head>区域中.

You are including JS from CDNs which is good. But in your example, you have JavaScript included in the <head> of the page. You should include your JS just above the </body> tag, to speed page load times. CSS should be included in the <head> area.

新近更新的官方jqplot示例页面条形图"显示了此加载顺序作为文档:

The newly updated official jqplot example page "Bar Charts" shows this loading order as documentation:

记录的订单:

<script type="text/javascript" src="../jquery.min.js"></script>
<script type="text/javascript" src="../jquery.jqplot.min.js"></script>
<script type="text/javascript" src="../jquery.jqplot.min.js"></script>
<script type="text/javascript" src="../plugins/jqplot.barRenderer.min.js"></script>
<script type="text/javascript" src="../plugins/jqplot.pieRenderer.min.js"></script>
<script type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script type="text/javascript" src="../plugins/jqplot.pointLabels.min.js"></script>
<link rel="stylesheet" type="text/css" hrf="../jquery.jqplot.min.css" />

请注意,官方页面的实际来源和文档似乎都出现了错误-jqplot被加载了两次.但是,它们在实际源中正确地将CSS加载到了页眉中-该示例显示了使用不合适的JS将其加载到页脚中的情况.这是示例页面中实际的JS加载顺序:

Note that both the actual source and the documentation of the official page appears to have an error - jqplot is being loaded twice. However, they load the CSS in the header properly in the actual source - the example shows it loading in the footer with the JS which is improper. Here's the actual JS loading order in the example page:

示例页面上的实际订单:

Actual order on example page:

<!-- Don't touch this! -->
<script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
<!-- Additional plugins go here -->
<script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
<script class="include" type="text/javascript" src="../plugins/jqplot.barRenderer.min.js"></script>
<script class="include" type="text/javascript" src="../plugins/jqplot.pieRenderer.min.js"></script>
<script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
<script class="include" type="text/javascript" src="../plugins/jqplot.pointLabels.min.js"></script>
<!-- End additional plugins -->

参考文献: http://www.jqplot.com/deploy/dist/examples/barTest.html http://developer.yahoo.com/performance/rules .html ,个人经历

References: http://www.jqplot.com/deploy/dist/examples/barTest.html, http://developer.yahoo.com/performance/rules.html, personal experience

这篇关于以特定顺序包括jqPlot文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆