minify html

This commit is contained in:
v 2018-11-28 18:10:39 +03:00
parent e446cb4ef8
commit cc3c1b1080

View File

@ -44,6 +44,7 @@ const Promise = require('bluebird')
const requestPromise = require('request-promise')
const sqlite = require( 'sqlite' )
const cheerio = require('cheerio')
const minify = require('html-minifier').minify
const langs = require('langs')
const encodeurl = require('encodeurl')
@ -580,8 +581,15 @@ class Article extends ArticleStub {
this.mimeType = 'text/html'
this.encoding = 'utf-8'
const out = dom.html()
return out
const minified = minify( out, {
collapseWhitespace: true,
conservativeCollapse: true,
decodeEntities: true,
sortAttributes: true,
sortClassName: true,
removeComments: true,
})
return minified
} catch ( err ) {
log( err )
return null