缩小signalr/hubs文件

Jon*_*onH 5 javascript asp.net minify signalr

我在我的应用程序中使用signalr并且正如此引用它:

<script src="/signalr/hubs" type="text/javascript"></script>

当然signalr是动态生成的javascript动态.当我运行yslow来改善我的Web应用程序的性能时,它抱怨singalr/hubs没有缩小.当我点击链接时,它显示了js,小片段样本:

/*!
 * ASP.NET SignalR JavaScript Library v2.1.1
 * http://signalr.net/
 *
 * Copyright Microsoft Open Technologies, Inc. All rights reserved.
 * Licensed under the Apache 2.0
 * https://github.com/SignalR/SignalR/blob/master/LICENSE.md
 *
 */

/// <reference path="..\..\SignalR.Client.JS\Scripts\jquery-1.6.4.js" />
/// <reference path="jquery.signalR.js" />
(function ($, window, undefined) {
    /// <param name="$" type="jQuery" />
    "use strict";

    if (typeof ($.signalR) !== "function") {
        throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
    }

    var signalR = $.signalR;

    function makeProxyCallback(hub, callback) {
        return function () {
            // Call the client hub method
            callback.apply(hub, $.makeArray(arguments));
        };
    }

    function registerHubProxies(instance, shouldSubscribe) {
        var key, hub, memberKey, memberValue, subscriptionMethod;
Run Code Online (Sandbox Code Playgroud)

如果自动生成此文件,我该如何缩小它?

编辑

也让我澄清我使用lcsk它可以发现在这里,它使用signalr.在这个包中有一个startup.cs文件,如下所示:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(RIMS.LCSK.Startup))]

    namespace RIMS.LCSK
    {
        public class Startup
        {
            public void Configuration(IAppBuilder app)
            {
                app.MapSignalR();
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我是否需要以某种方式告诉它在这一点上缩小?我见过这个:

SignalR hub.js缩小(但这似乎是使用global.asax文件)而且我也看到了这个:

https://github.com/SignalR/SignalR/issues/2403

但我不确定我需要用我所拥有的东西做什么.

Bra*_*tie 1

查看可扩展性指南。它列出了IJavaScriptMinifier您可以实现的接口来完成您想要的操作。(也许可以将其与优化/捆绑库或其他第 3 方压缩器结合使用)。