开发者

ASP.NET: Combres causes '$ is undefined' when jQuery is compressed

For anyone who has some know-how using Combres, this is for you:

My Combres.XML looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<combres xmlns='urn:combres'>

  <filters>
    <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />
  </filters >
  <cssMinifiers>
    <minifier name="yui" type="Combres.Minifiers.YuiCssMinifier, Combres">
      <param name="CssCompressionType" type="string" value="StockYuiCompressor" />
      <param name="ColumnWidth" type="int" value="-1" />
    </minifier>
  </cssMinifiers>
  <jsMinifiers>
    <minifier name="yui" type="Combres.Minifiers.YuiJSMinifier, Combres">
      <param name="IsVerboseL开发者_运维技巧ogging" type="bool" value="false" />
      <param name="IsObfuscateJavascript" type="bool" value="true" />
      <param name="PreserveAllSemicolons" type="bool" value="false" />
      <param name="DisableOptimizations" type="bool" value="true" />
      <param name="LineBreakPosition" type="int" value="-1" />
    </minifier>
  </jsMinifiers>
  <resourceSets url="~/combres.axd" defaultDuration="30"
                                defaultVersion="auto"
                                defaultDebugEnabled="false"
                                defaultCssMinifierRef="off" 
                                defaultJSMinifierRef="off"> 
    <resourceSet name="siteCss" type="css" minifierRef="yui">
      <resource path="~/css/jquery-ui-1.7.2.custom.css"  />
      <resource path="~/css/OMNIv2.css" />
      <resource path="~/css/dataTable.css" />
    </resourceSet>
    <resourceSet name="siteJs" type="js" >
      <resource path="~/js/jquery-1.4.2.min.js" minifierRef="off" />
      <resource path="~/js/jquery.jstree.min.js" minifierRef="off" />
      <resource path="~/js/jquery.dataTables.min.js" minifierRef="off" />
      <resource path="~/js/jquery.cookie.min.js" minifierRef="off" />
      <resource path="~/js/jquery-ui-1.7.2.custom.min.js" minifierRef="off" />
      <resource path="~/js/jquery.collapsible-v.2.1.3.js" minifierRef="yui" />
      <resource path="~/js/jquery.fileupload.js" minifierRef="yui" />
      <resource path="~/js/original/OMNIv2.js" minifierRef="yui" />
    </resourceSet>
  </resourceSets>
</combres>

With defaultDebugEnabled set to false, i.e. the module will now start running... inline Javascript and one of my ClientRegisterScriptBlocks blows up saying that '$ is undefined'. Obviously, the jQuery hasn't been loaded or is mangled in some way. If I actually run this with defaultDebugEnabled set to true, the combined JS runs fine and all references work. Is there any idea as to why this is happening? The log shows nothing out of the ordinary.

Output:

//These are from the master page
<link rel="stylesheet" type="text/css" href="/combres.axd/siteCss/1/"/>
<script type="text/javascript" src="/combres.axd/siteJs/a/"></script>

// This is in my Default.aspx 
<script type="text/javascript" >
   function pageLoad() {
    var $NavSlider = $("#NavSlider"); // THIS DOESN'T WORK, $ is undefined
   }
</script>


Interestingly enough, Combres must have some problem. Some JQuery source files would work while others wouldn't. It came down to how it was minified in some instances. Combres has some bugs to work out IMO.


Combres is encountering issues because it is trying to combine and minify files that are already minified. Try using the full, un-minified, javascript files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜