剑道js需要太多的时间,而下载在客户端



我在我的项目中使用剑道ui调度器,但是在客户端下载剑道js和css时需要太多时间,因此看到我们的网站速度很慢。为了克服这个问题,我们正在尝试下载剑道js和css按照请求的方式,只有在页面上的调度日历加载。在集成时,我们无法添加依赖项"kendo.directive"。请建议如何添加该依赖项或替代方法来减少如此多的延迟。

请查找相同的代码。

myApp.requires.push('kendo.directives');
myApp.controller('CalenderController',['$scope', '$http', 'StatsService', function ($scope, $http, StatsService) {
    var self=this;
    $scope.schedulerOptions = {
        date: new Date(),
        startTime: new Date(),
        showWorkHours: true,
        height: 600,
        views: [
            "day",
            {type: "week", selected: true},
        ],
        editable: {
            destroy: false,
            create: false,
            template: $("#editor").html()
        },
        timezone: "GMT",
        dataSource: {
            batch: true,
            transport: {
                read: function (options) {
                    url = '/consultants/applications/interviews';
                    $http.get(url).success(function (data, status, headers, config) {
                        options.success(data.result);
                    }).error(function (data, status, headers, config) {
                        options.error(data);
                    });
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options.models) {
                        return {models: kendo.stringify(options.models)};
                    }
                }
            },
            schema: {
                model: {
                    id: "interviewId",
                    fields: {
                        taskId: {from: "id", type: "number", editable: false},
                        candidateName: {from: "candidateName" , editable: false},
                        title: {from: "title", defaultValue: "No title" , editable: false},
                        companyName: {from: "companyName" , editable: false},
                        start: {type: "date", from: "interviewTiming", editable: false},
                        end: {type: "date", from: "interviewEndTiming" , editable: false},
                        candidateEmail: {from: "candidateEmail" , editable: false},
                        candidateMobile: {from: "candidateMobile" , editable: false}
                    }
                }
            }
        }
    };
}]);

使用自定义组合脚本,该脚本小于kendo.all.min.js

http://docs.telerik.com/kendo-ui/intro/installation/what-you-need构建脚本

…或者使用单独的脚本文件:

http://docs.telerik.com/kendo-ui/intro/installation/what-you-need individual-widget-scripts

在这两种情况下,加载的脚本文件的大小都将减少。

最新更新