53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
/**
|
|
* Sitespeed.io - How speedy is your site? (http://www.sitespeed.io)
|
|
* Copyright (c) 2014, Peter Hedenskog, Tobias Lidskog
|
|
* and other contributors
|
|
* Released under the Apache 2.0 License
|
|
*/
|
|
'use strict';
|
|
|
|
var hotlistUtil = require('../util/hotlist'),
|
|
render = require('../util/htmlRenderer'),
|
|
util = require('../util/util');
|
|
|
|
|
|
exports.task = function(result, config, cb) {
|
|
|
|
if (config.html) {
|
|
var limit = 10;
|
|
|
|
var assetsBySizeExcludingImages = hotlistUtil.getAssetsBySize(result.assets, limit);
|
|
var largestImages = hotlistUtil.getLargestImages(result.assets, limit);
|
|
var biggestDiffAssets = hotlistUtil.getLargestDiffBetweenLastModAndCache(result.assets, limit);
|
|
var heaviestPages = hotlistUtil.getLargestPages(result.pages, limit);
|
|
var lowestScoringPages = hotlistUtil.getLowestScoringPages(result.pages, limit);
|
|
var slowestAssets = result.assetsByTiming ? hotlistUtil.getSlowestAssets(result.assetsByTiming, limit) : [];
|
|
var worstCachedAssets = hotlistUtil.getWorstCachedAssets(result.assets, limit);
|
|
|
|
util.sortWithMaxLength(result.domains, function(domain, domain2) {
|
|
return domain2.total.stats.max - domain.total.stats.max;
|
|
}, limit);
|
|
|
|
var renderData = {
|
|
'largestImages': largestImages,
|
|
'biggestDiffInTimeAssets': biggestDiffAssets,
|
|
'largestAssets': assetsBySizeExcludingImages,
|
|
'slowestAssets': slowestAssets,
|
|
'slowestDomains': result.domains,
|
|
'heaviestPages': heaviestPages,
|
|
'lowestScoringPages': lowestScoringPages,
|
|
'worstCachedAssets': worstCachedAssets,
|
|
'config': config,
|
|
'numberOfPages': result.numberOfAnalyzedPages,
|
|
'pageMeta': {
|
|
'title': 'The hot list page',
|
|
'description': 'A quick way to see which pages and assets you need to look more into',
|
|
'isHotlist': true
|
|
}
|
|
};
|
|
render('hotlist', renderData, config.run.absResultDir, cb);
|
|
} else {
|
|
cb();
|
|
}
|
|
};
|