flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
1
VISUALIZACION/node_modules/htmlnano/.eslintignore
generated
vendored
Executable file
1
VISUALIZACION/node_modules/htmlnano/.eslintignore
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
lib/modules/example.es6
|
||||
103
VISUALIZACION/node_modules/htmlnano/CHANGELOG.md
generated
vendored
Executable file
103
VISUALIZACION/node_modules/htmlnano/CHANGELOG.md
generated
vendored
Executable file
|
|
@ -0,0 +1,103 @@
|
|||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.10] - 2018-08-03
|
||||
### Fixed
|
||||
- Merging `<script>` tags without leading `;` [#55].
|
||||
|
||||
|
||||
## [0.1.9] - 2018-04-29
|
||||
### Fixed
|
||||
- Default minification options safety [#50].
|
||||
|
||||
|
||||
## [0.1.8] - 2018-04-17
|
||||
### Fixed
|
||||
- ES6+ minification [#48].
|
||||
|
||||
|
||||
|
||||
## [0.1.7] - 2018-03-13
|
||||
### Fixed
|
||||
- Update dependencies which also fixes the SVG minification bug [#47].
|
||||
|
||||
|
||||
|
||||
## [0.1.6] - 2017-06-27
|
||||
### Fixed
|
||||
- "Not a function" error [#42].
|
||||
|
||||
|
||||
|
||||
## [0.1.5] - 2016-04-24
|
||||
### Added
|
||||
- Minify SVG [#28].
|
||||
- Merge `<script>` [#19].
|
||||
|
||||
### Changed
|
||||
- Remove redundant `type="submit"` from `<button>` [#31].
|
||||
|
||||
### Fixed
|
||||
- Windows build [#30].
|
||||
|
||||
|
||||
## [0.1.4] - 2016-02-16
|
||||
### Added
|
||||
- Minify JSON.
|
||||
- Merge multiple `<style>` into one.
|
||||
- Collapse boolean attributes.
|
||||
- Remove redundant attributes.
|
||||
- HTML minifiers benchmark [#22].
|
||||
|
||||
### Changed
|
||||
- Expand list of JSON-like mime types [#20].
|
||||
|
||||
|
||||
## [0.1.3] - 2016-02-09
|
||||
### Fixed
|
||||
- Don't alter HTML comments inside not relevant modules [#17].
|
||||
|
||||
|
||||
## [0.1.2] - 2016-02-07
|
||||
### Fixed
|
||||
- Don't remove conditional comments in safe mode [#13].
|
||||
- Downgrade: `String.startsWith -> String.search`.
|
||||
|
||||
|
||||
## [0.1.1] - 2016-01-31
|
||||
### Added
|
||||
- Minify CSS inside `<style>` tags and `style` attributes.
|
||||
- Minify JS inside `<script>` tags and `on*` attributes.
|
||||
|
||||
### Changed
|
||||
- Remove attributes that contains only white spaces.
|
||||
|
||||
|
||||
|
||||
[0.1.10]: https://github.com/posthtml/htmlnano/compare/0.1.9...0.1.10
|
||||
[0.1.9]: https://github.com/posthtml/htmlnano/compare/0.1.8...0.1.9
|
||||
[0.1.8]: https://github.com/posthtml/htmlnano/compare/0.1.7...0.1.8
|
||||
[0.1.7]: https://github.com/posthtml/htmlnano/compare/0.1.6...0.1.7
|
||||
[0.1.6]: https://github.com/posthtml/htmlnano/compare/0.1.5...0.1.6
|
||||
[0.1.5]: https://github.com/posthtml/htmlnano/compare/0.1.4...0.1.5
|
||||
[0.1.4]: https://github.com/posthtml/htmlnano/compare/0.1.3...0.1.4
|
||||
[0.1.3]: https://github.com/posthtml/htmlnano/compare/0.1.2...0.1.3
|
||||
[0.1.2]: https://github.com/posthtml/htmlnano/compare/0.1.1...0.1.2
|
||||
[0.1.1]: https://github.com/posthtml/htmlnano/compare/0.1.0...0.1.1
|
||||
|
||||
|
||||
[#55]: https://github.com/posthtml/htmlnano/issues/55
|
||||
[#50]: https://github.com/posthtml/htmlnano/issues/50
|
||||
[#48]: https://github.com/posthtml/htmlnano/issues/48
|
||||
[#47]: https://github.com/posthtml/htmlnano/issues/47
|
||||
[#42]: https://github.com/posthtml/htmlnano/issues/42
|
||||
[#31]: https://github.com/posthtml/htmlnano/issues/31
|
||||
[#30]: https://github.com/posthtml/htmlnano/issues/30
|
||||
[#28]: https://github.com/posthtml/htmlnano/issues/28
|
||||
[#22]: https://github.com/posthtml/htmlnano/issues/22
|
||||
[#20]: https://github.com/posthtml/htmlnano/issues/20
|
||||
[#19]: https://github.com/posthtml/htmlnano/issues/19
|
||||
[#17]: https://github.com/posthtml/htmlnano/issues/17
|
||||
[#13]: https://github.com/posthtml/htmlnano/issues/13
|
||||
21
VISUALIZACION/node_modules/htmlnano/LICENSE.txt
generated
vendored
Executable file
21
VISUALIZACION/node_modules/htmlnano/LICENSE.txt
generated
vendored
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Kirill Maltsev <maltsevkirill@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
490
VISUALIZACION/node_modules/htmlnano/README.md
generated
vendored
Executable file
490
VISUALIZACION/node_modules/htmlnano/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,490 @@
|
|||
# htmlnano
|
||||
[](http://badge.fury.io/js/htmlnano)
|
||||
[](https://travis-ci.org/posthtml/htmlnano)
|
||||
|
||||
Modular HTML minifier, built on top of the [PostHTML](https://github.com/posthtml/posthtml). Inspired by [cssnano](http://cssnano.co/).
|
||||
|
||||
## [Benchmark](https://github.com/maltsev/html-minifiers-benchmark/blob/master/README.md)
|
||||
[html-minifier]: https://www.npmjs.com/package/html-minifier
|
||||
[htmlnano]: https://www.npmjs.com/package/htmlnano
|
||||
|
||||
| Website | Source (KB) | [html-minifier] | [htmlnano] |
|
||||
|---------|------------:|----------------:|-----------:|
|
||||
| [stackoverflow.com](http://stackoverflow.com/) | 250 | 199 | 208 |
|
||||
| [github.com](http://github.com/) | 51 | 43 | 45 |
|
||||
| [en.wikipedia.org](https://en.wikipedia.org/wiki/Main_Page) | 71 | 64 | 68 |
|
||||
| [npmjs.com](https://www.npmjs.com/features) | 26 | 20 | 21 |
|
||||
| **Avg. minify rate** | 0% | **18%** | **14%** |
|
||||
|
||||
## Usage
|
||||
|
||||
### Gulp
|
||||
|
||||
```bash
|
||||
npm install --save-dev gulp-htmlnano
|
||||
```
|
||||
|
||||
```js
|
||||
var gulp = require('gulp');
|
||||
var htmlnano = require('gulp-htmlnano');
|
||||
var options = {
|
||||
removeComments: false
|
||||
};
|
||||
|
||||
gulp.task('default', function() {
|
||||
return gulp
|
||||
.src('./index.html')
|
||||
.pipe(htmlnano(options))
|
||||
.pipe(gulp.dest('./build'));
|
||||
});
|
||||
```
|
||||
|
||||
### Javascript
|
||||
|
||||
```js
|
||||
var htmlnano = require('htmlnano');
|
||||
var options = {
|
||||
removeEmptyAttributes: false, // Disable the module "removeEmptyAttributes"
|
||||
collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
||||
};
|
||||
|
||||
htmlnano
|
||||
.process(html, options)
|
||||
.then(function (result) {
|
||||
// result.html is minified
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
```
|
||||
|
||||
### PostHTML
|
||||
|
||||
Just add `htmlnano` as the last plugin:
|
||||
|
||||
```js
|
||||
var posthtml = require('posthtml');
|
||||
var options = {
|
||||
removeComments: false, // Disable the module "removeComments"
|
||||
collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
||||
};
|
||||
var posthtmlPlugins = [
|
||||
/* other PostHTML plugins */
|
||||
|
||||
require('htmlnano')(options)
|
||||
];
|
||||
|
||||
posthtml(posthtmlPlugins)
|
||||
.process(html)
|
||||
.then(function (result) {
|
||||
// result.html is minified
|
||||
})
|
||||
.catch(function (err) {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
// You can also use htmlnano modules separately:
|
||||
posthtml([
|
||||
require('htmlnano/lib/modules/mergeStyles').default
|
||||
]).process(html);
|
||||
```
|
||||
|
||||
## Modules
|
||||
|
||||
By default the modules should only perform safe transforms, see the module documentation below for details.
|
||||
You can disable modules by passing `false` as option, and enable them by passing `true`.
|
||||
|
||||
### collapseWhitespace
|
||||
|
||||
Collapses redundant white spaces (including new lines). It doesn’t affect white spaces in the elements `<style>`, `<textarea>`, `<script>` and `<pre>`.
|
||||
|
||||
##### Options
|
||||
|
||||
- `conservative` — collapses all redundant white spaces to 1 space (default)
|
||||
- `all` — collapses all redundant white spaces
|
||||
|
||||
##### Side effects
|
||||
|
||||
`<i>hello</i> <i>world</i>` after minification will be rendered as `helloworld`.
|
||||
To prevent that use `conservative` option (this is the default option).
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<div>
|
||||
hello world!
|
||||
<style>div { color: red; } </style>
|
||||
</div>
|
||||
```
|
||||
|
||||
Minified (with `all`):
|
||||
|
||||
```html
|
||||
<div>hello world!<style>div { color: red; } </style></div>
|
||||
```
|
||||
|
||||
Minified (with `conservative`):
|
||||
|
||||
```html
|
||||
<div> hello world! <style>div { color: red; } </style> </div>
|
||||
```
|
||||
|
||||
### removeComments
|
||||
|
||||
##### Options
|
||||
|
||||
- `safe` – removes all HTML comments except the conditional comments and [`<!--noindex--><!--/noindex-->`](https://yandex.com/support/webmaster/controlling-robot/html.xml) (default)
|
||||
- `all` — removes all HTML comments
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<div><!-- test --></div>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<div></div>
|
||||
```
|
||||
|
||||
### removeEmptyAttributes
|
||||
|
||||
Removes empty [safe-to-remove](https://github.com/posthtml/htmlnano/blob/master/lib/modules/removeEmptyAttributes.es6) attributes.
|
||||
|
||||
##### Side effects
|
||||
|
||||
This module could break your styles or JS if you use selectors with attributes:
|
||||
|
||||
```CSS
|
||||
img[style=""] {
|
||||
margin: 10px;
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<img src="foo.jpg" alt="" style="">
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<img src="foo.jpg" alt="">
|
||||
```
|
||||
|
||||
### minifyCss
|
||||
|
||||
Minifies CSS with [cssnano](http://cssnano.co/) inside `<style>` tags and `style` attributes.
|
||||
|
||||
##### Options
|
||||
|
||||
Css transforms are set to the `safe` option as a default (this should have very little side-effects):
|
||||
|
||||
```Json
|
||||
"minifyCss": {
|
||||
"safe": true
|
||||
}
|
||||
```
|
||||
|
||||
See [the documentation of cssnano](http://cssnano.co/optimisations/).
|
||||
For example you can [keep outdated vendor prefixes](http://cssnano.co/optimisations/#discard-outdated-vendor-prefixes):
|
||||
|
||||
```js
|
||||
htmlnano.process(html, {
|
||||
minifyCss: {
|
||||
autoprefixer: false
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<div>
|
||||
<style>
|
||||
h1 {
|
||||
margin: 10px 10px 10px 10px;
|
||||
color: #ff0000;
|
||||
}
|
||||
</style>
|
||||
</div>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<div>
|
||||
<style>h1{margin:10px;color:red}</style>
|
||||
</div>
|
||||
```
|
||||
|
||||
### minifyJs
|
||||
|
||||
Minifies JS with [Terser](https://github.com/fabiosantoscode/terser) inside `<script>` tags.
|
||||
|
||||
##### Options
|
||||
|
||||
See [the API documentation of Terser](https://github.com/fabiosantoscode/terser#api-reference)
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<div>
|
||||
<script>
|
||||
/* comment */
|
||||
var foo = function () {
|
||||
|
||||
};
|
||||
</script>
|
||||
</div>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<div>
|
||||
<script>var foo=function(){};</script>
|
||||
</div>
|
||||
```
|
||||
|
||||
### minifyJson
|
||||
|
||||
Minifies JSON inside `<script type="application/json"></script>`.
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<script type="application/json">
|
||||
{
|
||||
"user": "me"
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<script type="application/json">{"user":"me"}</script>
|
||||
```
|
||||
|
||||
### minifySvg
|
||||
|
||||
Minifies SVG inside `<svg>` tags with [SVGO](https://github.com/svg/svgo/).
|
||||
|
||||
##### Options
|
||||
|
||||
See [the documentation of SVGO](https://github.com/svg/svgo/blob/master/README.md)
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<svg version="1.1" baseProfile="full" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="100%" height="100%" fill="red" />
|
||||
|
||||
<circle cx="150" cy="100" r="80" fill="green" />
|
||||
|
||||
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>
|
||||
</svg>`
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<svg baseProfile="full" width="300" height="200" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" fill="red"/><circle cx="150" cy="100" r="80" fill="green"/><text x="150" y="125" font-size="60" text-anchor="middle" fill="#fff">SVG</text></svg>
|
||||
```
|
||||
|
||||
### removeRedundantAttributes
|
||||
|
||||
Removes redundant attributes from tags if they contain default values:
|
||||
|
||||
- `method="get"` from `<form>`
|
||||
- `type="text"` from `<input>`
|
||||
- `type="submit"` from `<button>`
|
||||
- `language="javascript"` and `type="text/javascript"` from `<script>`
|
||||
- `charset` from `<script>` if it's an external script
|
||||
- `media="all"` from `<style>` and `<link>`
|
||||
|
||||
##### Options
|
||||
|
||||
This module is disabled by default, change option to true to enable this module.
|
||||
|
||||
##### Side effects
|
||||
|
||||
This module could break your styles or JS if you use selectors with attributes:
|
||||
|
||||
```CSS
|
||||
form[method="get"] {
|
||||
color: red;
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<form method="get">
|
||||
<input type="text">
|
||||
</form>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<form>
|
||||
<input>
|
||||
</form>
|
||||
```
|
||||
|
||||
### collapseBooleanAttributes
|
||||
|
||||
Collapses boolean attributes (like `disabled`) to the minimized form.
|
||||
|
||||
##### Side effects
|
||||
|
||||
This module could break your styles or JS if you use selectors with attributes:
|
||||
|
||||
```CSS
|
||||
button[disabled="disabled"] {
|
||||
color: red;
|
||||
}
|
||||
```
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<button disabled="disabled">click</button>
|
||||
<script defer=""></script>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<button disabled>click</button>
|
||||
<script defer></script>
|
||||
```
|
||||
|
||||
### mergeStyles
|
||||
|
||||
Merges multiple `<style>` with the same `media` and `type` into one tag.
|
||||
`<style scoped>...</style>` are skipped.
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<style>h1 { color: red }</style>
|
||||
<style media="print">div { color: blue }</style>
|
||||
|
||||
<style type="text/css" media="print">a {}</style>
|
||||
<style>div { font-size: 20px }</style>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<style>h1 { color: red } div { font-size: 20px }</style>
|
||||
<style media="print">div { color: blue } a {}</style>
|
||||
```
|
||||
|
||||
### mergeScripts
|
||||
|
||||
Merge multiple `<script>` with the same attributes (`id, class, type, async, defer`) into one (last) tag.
|
||||
|
||||
##### Side effects
|
||||
|
||||
It could break your code if the tags with different attributes share the same variable scope.
|
||||
See the example below.
|
||||
|
||||
##### Example
|
||||
|
||||
Source:
|
||||
|
||||
```html
|
||||
<script>var foo = 'A:1';</script>
|
||||
<script class="test">foo = 'B:1';</script>
|
||||
<script type="text/javascript">foo = 'A:2';</script>
|
||||
<script defer>foo = 'C:1';</script>
|
||||
<script>foo = 'A:3';</script>
|
||||
<script defer="defer">foo = 'C:2';</script>
|
||||
<script class="test" type="text/javascript">foo = 'B:2';</script>
|
||||
```
|
||||
|
||||
Minified:
|
||||
|
||||
```html
|
||||
<script>var foo = 'A:1'; foo = 'A:2'; foo = 'A:3';</script>
|
||||
<script defer="defer">foo = 'C:1'; foo = 'C:2';</script>
|
||||
<script class="test" type="text/javascript">foo = 'B:1'; foo = 'B:2';</script>
|
||||
```
|
||||
|
||||
### custom
|
||||
|
||||
It's also possible to pass custom modules in the minifier.
|
||||
|
||||
As a function:
|
||||
|
||||
```js
|
||||
var options = {
|
||||
custom: function (tree, options) {
|
||||
// Some minification
|
||||
return tree;
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Or as a list of functions:
|
||||
|
||||
```js
|
||||
var options = {
|
||||
custom: [
|
||||
function (tree, options) {
|
||||
// Some minification
|
||||
return tree;
|
||||
},
|
||||
|
||||
function (tree, options) {
|
||||
// Some other minification
|
||||
return tree;
|
||||
}
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
`options` is an object with all options that were passed to the plugin.
|
||||
|
||||
## Contribute
|
||||
|
||||
Since the minifier is modular, it's very easy to add new modules:
|
||||
|
||||
1. Create a ES6-file inside `lib/modules/` with a function that does some minification. For example you can check [`lib/modules/example.es6`](https://github.com/posthtml/htmlnano/blob/master/lib/modules/example.es6).
|
||||
|
||||
2. Add the module in [the modules array](https://github.com/posthtml/htmlnano/blob/master/lib/htmlnano.es6#L5). The modules are applied from top to bottom. So you can choose the order for your module.
|
||||
|
||||
3. Create a JS-file inside `test/modules/` with some unit-tests.
|
||||
|
||||
4. Describe your module in the section "[Modules](https://github.com/posthtml/htmlnano/blob/master/README.md#modules)".
|
||||
|
||||
5. Send me a pull request.
|
||||
|
||||
Other types of contribution (bug fixes, documentation improves, etc) are also welcome!
|
||||
Would like to contribute, but don't have any ideas what to do? Check out [our issues](https://github.com/posthtml/htmlnano/labels/help%20wanted).
|
||||
1
VISUALIZACION/node_modules/htmlnano/index.js
generated
vendored
Executable file
1
VISUALIZACION/node_modules/htmlnano/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1 @@
|
|||
module.exports = require('./lib/htmlnano').default;
|
||||
14
VISUALIZACION/node_modules/htmlnano/lib/helpers.js
generated
vendored
Executable file
14
VISUALIZACION/node_modules/htmlnano/lib/helpers.js
generated
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.isComment = isComment;
|
||||
exports.isConditionalComment = isConditionalComment;
|
||||
function isComment(content) {
|
||||
return (content || '').trim().search('<!--') === 0;
|
||||
}
|
||||
|
||||
function isConditionalComment(content) {
|
||||
return (content || '').trim().search(/<!--\[if/) === 0;
|
||||
}
|
||||
94
VISUALIZACION/node_modules/htmlnano/lib/htmlnano.js
generated
vendored
Executable file
94
VISUALIZACION/node_modules/htmlnano/lib/htmlnano.js
generated
vendored
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _objectAssign = require('object-assign');
|
||||
|
||||
var _objectAssign2 = _interopRequireDefault(_objectAssign);
|
||||
|
||||
var _posthtml = require('posthtml');
|
||||
|
||||
var _posthtml2 = _interopRequireDefault(_posthtml);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// Array of all enabled modules
|
||||
var defaultOptions = {
|
||||
removeComments: 'safe',
|
||||
removeEmptyAttributes: true,
|
||||
removeRedundantAttributes: false,
|
||||
collapseWhitespace: 'conservative',
|
||||
collapseBooleanAttributes: true,
|
||||
mergeStyles: true,
|
||||
mergeScripts: true,
|
||||
minifyCss: {
|
||||
safe: true
|
||||
},
|
||||
minifyJs: {},
|
||||
minifyJson: {},
|
||||
minifySvg: {},
|
||||
custom: []
|
||||
};
|
||||
|
||||
function htmlnano() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
|
||||
return function minifier(tree) {
|
||||
options = (0, _objectAssign2.default)({}, defaultOptions, options);
|
||||
var promise = Promise.resolve(tree);
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
var _loop = function _loop() {
|
||||
var moduleName = _step.value;
|
||||
|
||||
if (!options[moduleName]) {
|
||||
// The module is disabled
|
||||
return 'continue';
|
||||
}
|
||||
|
||||
if (defaultOptions[moduleName] === undefined) {
|
||||
throw new Error('Module "' + moduleName + '" is not defined');
|
||||
}
|
||||
|
||||
var module = require('./modules/' + moduleName);
|
||||
promise = promise.then(function (tree) {
|
||||
return module.default(tree, options, options[moduleName]);
|
||||
});
|
||||
};
|
||||
|
||||
for (var _iterator = Object.keys(options)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var _ret = _loop();
|
||||
|
||||
if (_ret === 'continue') continue;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return promise;
|
||||
};
|
||||
}
|
||||
|
||||
htmlnano.process = function (html, options) {
|
||||
return (0, _posthtml2.default)([htmlnano(options)]).process(html);
|
||||
};
|
||||
|
||||
htmlnano.defaultOptions = defaultOptions;
|
||||
|
||||
exports.default = htmlnano;
|
||||
48
VISUALIZACION/node_modules/htmlnano/lib/modules/collapseBooleanAttributes.js
generated
vendored
Executable file
48
VISUALIZACION/node_modules/htmlnano/lib/modules/collapseBooleanAttributes.js
generated
vendored
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = collapseBooleanAttributes;
|
||||
// Source: https://github.com/kangax/html-minifier/issues/63
|
||||
var booleanAttributes = ['allowfullscreen', 'async', 'autofocus', 'autoplay', 'checked', 'compact', 'controls', 'declare', 'default', 'defaultchecked', 'defaultmuted', 'defaultselected', 'defer', 'disabled', 'enabled', 'formnovalidate', 'hidden', 'indeterminate', 'inert', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nohref', 'noresize', 'noshade', 'novalidate', 'nowrap', 'open', 'pauseonexit', 'readonly', 'required', 'reversed', 'scoped', 'seamless', 'selected', 'sortable', 'truespeed', 'typemustmatch', 'visible'];
|
||||
|
||||
var booleanAttributesIndex = {};
|
||||
booleanAttributes.forEach(function (attributeName) {
|
||||
return booleanAttributesIndex[attributeName] = true;
|
||||
});
|
||||
|
||||
function collapseBooleanAttributes(tree) {
|
||||
tree.match({ attrs: true }, function (node) {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = Object.keys(node.attrs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var attrName = _step.value;
|
||||
|
||||
if (booleanAttributesIndex[attrName]) {
|
||||
node.attrs[attrName] = true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
43
VISUALIZACION/node_modules/htmlnano/lib/modules/collapseWhitespace.js
generated
vendored
Executable file
43
VISUALIZACION/node_modules/htmlnano/lib/modules/collapseWhitespace.js
generated
vendored
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = collapseWhitespace;
|
||||
|
||||
var _helpers = require('../helpers');
|
||||
|
||||
var noWhitespaceCollapseElements = ['script', 'style', 'pre', 'textarea'];
|
||||
|
||||
/** Collapses redundant whitespaces */
|
||||
function collapseWhitespace(tree, options, collapseType) {
|
||||
if (collapseType !== 'conservative' && collapseType !== 'all') {
|
||||
collapseType = 'conservative';
|
||||
}
|
||||
|
||||
tree.forEach(function (node, index) {
|
||||
if (typeof node === 'string' && !(0, _helpers.isComment)(node)) {
|
||||
node = collapseRedundantWhitespaces(node, collapseType, tree.walk !== undefined);
|
||||
}
|
||||
|
||||
var isAllowCollapseWhitespace = noWhitespaceCollapseElements.indexOf(node.tag) === -1;
|
||||
if (node.content && node.content.length && isAllowCollapseWhitespace) {
|
||||
node.content = collapseWhitespace(node.content, options, collapseType);
|
||||
}
|
||||
|
||||
tree[index] = node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
function collapseRedundantWhitespaces(text, collapseType) {
|
||||
var isTopLevel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
||||
|
||||
text = text && text.length > 0 ? text.replace(/\s+/g, ' ') : '';
|
||||
if (collapseType === 'all' || isTopLevel) {
|
||||
text = text.trim();
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
22
VISUALIZACION/node_modules/htmlnano/lib/modules/custom.js
generated
vendored
Executable file
22
VISUALIZACION/node_modules/htmlnano/lib/modules/custom.js
generated
vendored
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = custom;
|
||||
/** Meta-module that runs custom modules */
|
||||
function custom(tree, options, customModules) {
|
||||
if (!customModules) {
|
||||
return tree;
|
||||
}
|
||||
|
||||
if (!Array.isArray(customModules)) {
|
||||
customModules = [customModules];
|
||||
}
|
||||
|
||||
customModules.forEach(function (customModule) {
|
||||
tree = customModule(tree, options);
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
80
VISUALIZACION/node_modules/htmlnano/lib/modules/mergeScripts.js
generated
vendored
Executable file
80
VISUALIZACION/node_modules/htmlnano/lib/modules/mergeScripts.js
generated
vendored
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = mergeScripts;
|
||||
/* Merge multiple <script> into one */
|
||||
function mergeScripts(tree) {
|
||||
var scriptNodesIndex = {};
|
||||
|
||||
tree.match({ tag: 'script' }, function (node) {
|
||||
var nodeAttrs = node.attrs || {};
|
||||
if (nodeAttrs.src) {
|
||||
return node;
|
||||
}
|
||||
|
||||
var scriptType = nodeAttrs.type || 'text/javascript';
|
||||
if (scriptType !== 'text/javascript' && scriptType !== 'application/javascript') {
|
||||
return node;
|
||||
}
|
||||
|
||||
var scriptKey = JSON.stringify({
|
||||
id: nodeAttrs.id,
|
||||
class: nodeAttrs.class,
|
||||
type: scriptType,
|
||||
defer: nodeAttrs.defer !== undefined,
|
||||
async: nodeAttrs.async !== undefined
|
||||
});
|
||||
if (!scriptNodesIndex[scriptKey]) {
|
||||
scriptNodesIndex[scriptKey] = [];
|
||||
}
|
||||
|
||||
scriptNodesIndex[scriptKey].push(node);
|
||||
return node;
|
||||
});
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
var _loop = function _loop() {
|
||||
var scriptKey = _step.value;
|
||||
|
||||
var scriptNodes = scriptNodesIndex[scriptKey];
|
||||
var lastScriptNode = scriptNodes.pop();
|
||||
scriptNodes.reverse().forEach(function (scriptNode) {
|
||||
var scriptContent = (scriptNode.content || []).join(' ');
|
||||
scriptContent = scriptContent.trim();
|
||||
if (scriptContent.slice(-1) !== ';') {
|
||||
scriptContent += ';';
|
||||
}
|
||||
|
||||
lastScriptNode.content.unshift(scriptContent);
|
||||
|
||||
scriptNode.tag = false;
|
||||
scriptNode.content = [];
|
||||
});
|
||||
};
|
||||
|
||||
for (var _iterator = Object.keys(scriptNodesIndex)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
_loop();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tree;
|
||||
}
|
||||
34
VISUALIZACION/node_modules/htmlnano/lib/modules/mergeStyles.js
generated
vendored
Executable file
34
VISUALIZACION/node_modules/htmlnano/lib/modules/mergeStyles.js
generated
vendored
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = mergeStyles;
|
||||
/* Merge multiple <style> into one */
|
||||
function mergeStyles(tree) {
|
||||
var styleNodes = {};
|
||||
|
||||
tree.match({ tag: 'style' }, function (node) {
|
||||
var nodeAttrs = node.attrs || {};
|
||||
// Skip <style scoped></style>
|
||||
// https://developer.mozilla.org/en/docs/Web/HTML/Element/style
|
||||
if (nodeAttrs.scoped !== undefined) {
|
||||
return node;
|
||||
}
|
||||
|
||||
var styleType = nodeAttrs.type || 'text/css';
|
||||
var styleMedia = nodeAttrs.media || 'all';
|
||||
var styleKey = styleType + '_' + styleMedia;
|
||||
if (styleNodes[styleKey]) {
|
||||
var styleContent = (node.content || []).join(' ');
|
||||
styleNodes[styleKey].content.push(' ' + styleContent);
|
||||
return '';
|
||||
}
|
||||
|
||||
node.content = node.content || [];
|
||||
styleNodes[styleKey] = node;
|
||||
return node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
50
VISUALIZACION/node_modules/htmlnano/lib/modules/minifyCss.js
generated
vendored
Executable file
50
VISUALIZACION/node_modules/htmlnano/lib/modules/minifyCss.js
generated
vendored
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = minifyCss;
|
||||
|
||||
var _cssnano = require('cssnano');
|
||||
|
||||
var _cssnano2 = _interopRequireDefault(_cssnano);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/** Minify CSS with cssnano */
|
||||
function minifyCss(tree, options, cssnanoOptions) {
|
||||
var promises = [];
|
||||
tree.walk(function (node) {
|
||||
if (node.tag === 'style' && node.content && node.content.length) {
|
||||
promises.push(processStyleNode(node, cssnanoOptions));
|
||||
} else if (node.attrs && node.attrs.style) {
|
||||
promises.push(processStyleAttr(node, cssnanoOptions));
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(function () {
|
||||
return tree;
|
||||
});
|
||||
}
|
||||
|
||||
function processStyleNode(styleNode, cssnanoOptions) {
|
||||
return _cssnano2.default.process(Array.isArray(styleNode.content) ? styleNode.content.join(' ') : styleNode.content, cssnanoOptions).then(function (result) {
|
||||
return styleNode.content = [result.css];
|
||||
});
|
||||
}
|
||||
|
||||
function processStyleAttr(node, cssnanoOptions) {
|
||||
// CSS "color: red;" is invalid. Therefore it should be wrapped inside some selector:
|
||||
// a{color: red;}
|
||||
var wrapperStart = 'a{';
|
||||
var wrapperEnd = '}';
|
||||
var wrappedStyle = wrapperStart + (node.attrs.style || '') + wrapperEnd;
|
||||
|
||||
return _cssnano2.default.process(wrappedStyle, cssnanoOptions).then(function (result) {
|
||||
var minifiedCss = result.css;
|
||||
// Remove wrapperStart at the start and wrapperEnd at the end of minifiedCss
|
||||
node.attrs.style = minifiedCss.substring(wrapperStart.length, minifiedCss.length - wrapperEnd.length);
|
||||
});
|
||||
}
|
||||
94
VISUALIZACION/node_modules/htmlnano/lib/modules/minifyJs.js
generated
vendored
Executable file
94
VISUALIZACION/node_modules/htmlnano/lib/modules/minifyJs.js
generated
vendored
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = minifyJs;
|
||||
|
||||
var _terser = require('terser');
|
||||
|
||||
var _terser2 = _interopRequireDefault(_terser);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/** Minify JS with Terser */
|
||||
function minifyJs(tree, options, terserOptions) {
|
||||
|
||||
tree.match({ tag: 'script' }, function (node) {
|
||||
var nodeAttrs = node.attrs || {};
|
||||
var mimeType = nodeAttrs.type || 'text/javascript';
|
||||
if (mimeType === 'text/javascript' || mimeType === 'application/javascript') {
|
||||
return processScriptNode(node, terserOptions);
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
tree.match({ attrs: true }, function (node) {
|
||||
return processNodeWithOnAttrs(node, terserOptions);
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
function processScriptNode(scriptNode, terserOptions) {
|
||||
var js = (scriptNode.content || []).join(' ').trim();
|
||||
if (!js) {
|
||||
return scriptNode;
|
||||
}
|
||||
|
||||
var result = _terser2.default.minify(js, terserOptions);
|
||||
if (result.error) {
|
||||
throw new Error(result.error);
|
||||
}
|
||||
if (result.code === undefined) {
|
||||
return scriptNode;
|
||||
}
|
||||
|
||||
scriptNode.content = [result.code];
|
||||
|
||||
return scriptNode;
|
||||
}
|
||||
|
||||
function processNodeWithOnAttrs(node, terserOptions) {
|
||||
var jsWrapperStart = 'function _(){';
|
||||
var jsWrapperEnd = '}';
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = Object.keys(node.attrs || {})[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var attrName = _step.value;
|
||||
|
||||
if (attrName.search('on') !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For example onclick="return false" is valid,
|
||||
// but "return false;" is invalid (error: 'return' outside of function)
|
||||
// Therefore the attribute's code should be wrapped inside function:
|
||||
// "function _(){return false;}"
|
||||
var wrappedJs = jsWrapperStart + node.attrs[attrName] + jsWrapperEnd;
|
||||
var wrappedMinifiedJs = _terser2.default.minify(wrappedJs, terserOptions).code;
|
||||
var minifiedJs = wrappedMinifiedJs.substring(jsWrapperStart.length, wrappedMinifiedJs.length - jsWrapperEnd.length);
|
||||
node.attrs[attrName] = minifiedJs;
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
27
VISUALIZACION/node_modules/htmlnano/lib/modules/minifyJson.js
generated
vendored
Executable file
27
VISUALIZACION/node_modules/htmlnano/lib/modules/minifyJson.js
generated
vendored
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = minifyJson;
|
||||
/* Minify JSON inside <script> tags */
|
||||
function minifyJson(tree) {
|
||||
// Match all <script> tags which have JSON mime type
|
||||
tree.match({ tag: 'script', attrs: { type: /(\/|\+)json/ } }, function (node) {
|
||||
var content = (node.content || []).join('');
|
||||
if (!content) {
|
||||
return node;
|
||||
}
|
||||
|
||||
try {
|
||||
content = JSON.stringify(JSON.parse(content));
|
||||
} catch (error) {
|
||||
return node;
|
||||
}
|
||||
|
||||
node.content = [content];
|
||||
return node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
40
VISUALIZACION/node_modules/htmlnano/lib/modules/minifySvg.js
generated
vendored
Executable file
40
VISUALIZACION/node_modules/htmlnano/lib/modules/minifySvg.js
generated
vendored
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = minifySvg;
|
||||
|
||||
var _svgo = require('svgo');
|
||||
|
||||
var _svgo2 = _interopRequireDefault(_svgo);
|
||||
|
||||
var _posthtmlRender = require('posthtml-render');
|
||||
|
||||
var _posthtmlRender2 = _interopRequireDefault(_posthtmlRender);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/** Minify SVG with SVGO */
|
||||
function minifySvg(tree, options) {
|
||||
var svgoOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
|
||||
var promises = [];
|
||||
var svgo = new _svgo2.default(svgoOptions);
|
||||
|
||||
tree.match({ tag: 'svg' }, function (node) {
|
||||
var svgStr = (0, _posthtmlRender2.default)(node);
|
||||
var promise = svgo.optimize(svgStr).then(function (result) {
|
||||
node.tag = false;
|
||||
node.attrs = {};
|
||||
node.content = result.data;
|
||||
});
|
||||
promises.push(promise);
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(function () {
|
||||
return tree;
|
||||
});
|
||||
}
|
||||
54
VISUALIZACION/node_modules/htmlnano/lib/modules/removeComments.js
generated
vendored
Executable file
54
VISUALIZACION/node_modules/htmlnano/lib/modules/removeComments.js
generated
vendored
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = removeComments;
|
||||
|
||||
var _helpers = require('../helpers');
|
||||
|
||||
/** Removes HTML comments */
|
||||
function removeComments(tree, options, removeType) {
|
||||
if (removeType !== 'all' && removeType !== 'safe') {
|
||||
removeType = 'safe';
|
||||
}
|
||||
|
||||
tree.walk(function (node) {
|
||||
if (node.contents && node.contents.length) {
|
||||
node.contents = node.contents.filter(function (content) {
|
||||
return !isCommentToRemove(content, removeType);
|
||||
});
|
||||
} else if (isCommentToRemove(node, removeType)) {
|
||||
node = '';
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
function isCommentToRemove(text, removeType) {
|
||||
if (typeof text !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(0, _helpers.isComment)(text)) {
|
||||
// Not HTML comment
|
||||
return false;
|
||||
}
|
||||
|
||||
var isNoindex = text === '<!--noindex-->' || text === '<!--/noindex-->';
|
||||
if (removeType === 'safe' && isNoindex) {
|
||||
// Don't remove noindex comments.
|
||||
// See: https://yandex.com/support/webmaster/controlling-robot/html.xml
|
||||
return false;
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Conditional_comment
|
||||
if (removeType === 'safe' && (0, _helpers.isConditionalComment)(text)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
33
VISUALIZACION/node_modules/htmlnano/lib/modules/removeEmptyAttributes.js
generated
vendored
Executable file
33
VISUALIZACION/node_modules/htmlnano/lib/modules/removeEmptyAttributes.js
generated
vendored
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = removeEmptyAttributes;
|
||||
// Source: https://www.w3.org/TR/html4/sgml/dtd.html#events (Generic Attributes)
|
||||
var safeToRemoveAttrs = ['id', 'class', 'style', 'title', 'lang', 'dir', 'onclick', 'ondblclick', 'onmousedown', 'onmouseup', 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress', 'onkeydown', 'onkeyup'];
|
||||
|
||||
/** Removes empty attributes */
|
||||
function removeEmptyAttributes(tree) {
|
||||
tree.walk(function (node) {
|
||||
if (!node.attrs) {
|
||||
return node;
|
||||
}
|
||||
|
||||
Object.keys(node.attrs).forEach(function (attrName) {
|
||||
var attrNameLower = attrName.toLowerCase();
|
||||
if (safeToRemoveAttrs.indexOf(attrNameLower) === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var attrValue = node.attrs[attrName];
|
||||
if (attrValue === '' || (attrValue || '').match(/^\s+$/)) {
|
||||
delete node.attrs[attrName];
|
||||
}
|
||||
});
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
87
VISUALIZACION/node_modules/htmlnano/lib/modules/removeRedundantAttributes.js
generated
vendored
Executable file
87
VISUALIZACION/node_modules/htmlnano/lib/modules/removeRedundantAttributes.js
generated
vendored
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = removeRedundantAttributes;
|
||||
var redundantAttributes = {
|
||||
'form': {
|
||||
'method': 'get'
|
||||
},
|
||||
|
||||
'input': {
|
||||
'type': 'text'
|
||||
},
|
||||
|
||||
'button': {
|
||||
'type': 'submit'
|
||||
},
|
||||
|
||||
'script': {
|
||||
'language': 'javascript',
|
||||
'type': 'text/javascript',
|
||||
// Remove attribute if the function returns false
|
||||
'charset': function charset(node) {
|
||||
// The charset attribute only really makes sense on “external” SCRIPT elements:
|
||||
// http://perfectionkills.com/optimizing-html/#8_script_charset
|
||||
return node.attrs && !node.attrs.src;
|
||||
}
|
||||
},
|
||||
|
||||
'style': {
|
||||
'media': 'all',
|
||||
'type': 'text/css'
|
||||
},
|
||||
|
||||
'link': {
|
||||
'media': 'all'
|
||||
}
|
||||
};
|
||||
|
||||
/** Removes redundant attributes */
|
||||
function removeRedundantAttributes(tree) {
|
||||
var tags = Object.keys(redundantAttributes);
|
||||
var tagMatchRegExp = new RegExp('^(' + tags.join('|') + ')$');
|
||||
tree.match({ tag: tagMatchRegExp }, function (node) {
|
||||
var tagRedundantAttributes = redundantAttributes[node.tag];
|
||||
node.attrs = node.attrs || {};
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = Object.keys(tagRedundantAttributes)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var redundantAttributeName = _step.value;
|
||||
|
||||
var tagRedundantAttributeValue = tagRedundantAttributes[redundantAttributeName];
|
||||
var isRemove = false;
|
||||
if (typeof tagRedundantAttributeValue === 'function') {
|
||||
isRemove = tagRedundantAttributeValue(node);
|
||||
} else if (node.attrs[redundantAttributeName] === tagRedundantAttributeValue) {
|
||||
isRemove = true;
|
||||
}
|
||||
|
||||
if (isRemove) {
|
||||
delete node.attrs[redundantAttributeName];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
});
|
||||
|
||||
return tree;
|
||||
}
|
||||
54
VISUALIZACION/node_modules/htmlnano/package.json
generated
vendored
Executable file
54
VISUALIZACION/node_modules/htmlnano/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"name": "htmlnano",
|
||||
"version": "0.1.10",
|
||||
"description": "Modular HTML minifier, built on top of the PostHTML",
|
||||
"main": "index.js",
|
||||
"author": "Kirill Maltsev <maltsevkirill@gmail.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"compile": "rimraf lib/*.js && rimraf lib/modules/*.js && babel -d lib/ lib/",
|
||||
"lint": "eslint *.js lib/*.es6 lib/modules/*.es6 test/",
|
||||
"pretest": "npm run lint && npm run compile",
|
||||
"test": ":",
|
||||
"posttest": "mocha --require babel-core/register --recursive --check-leaks --globals addresses",
|
||||
"prepare": "npm run compile"
|
||||
},
|
||||
"keywords": [
|
||||
"posthtml",
|
||||
"posthtml-plugin",
|
||||
"html",
|
||||
"postproccessor",
|
||||
"minifier"
|
||||
],
|
||||
"babel": {
|
||||
"presets": [
|
||||
"es2015"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"cssnano": "^3.4.0",
|
||||
"object-assign": "^4.0.1",
|
||||
"posthtml": "^0.11.3",
|
||||
"posthtml-render": "^1.1.4",
|
||||
"svgo": "^1.0.5",
|
||||
"terser": "^3.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^8.2.6",
|
||||
"babel-preset-es2015": "^6.1.18",
|
||||
"eslint": "^5.2.0",
|
||||
"expect": "^23.4.0",
|
||||
"mocha": "^5.2.0",
|
||||
"rimraf": "^2.6.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/posthtml/htmlnano.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/posthtml/htmlnano/issues"
|
||||
},
|
||||
"homepage": "https://github.com/posthtml/htmlnano"
|
||||
}
|
||||
14
VISUALIZACION/node_modules/htmlnano/test.html
generated
vendored
Executable file
14
VISUALIZACION/node_modules/htmlnano/test.html
generated
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<script src="./app.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script>
|
||||
console.log('hello');
|
||||
const p = new Point(10, 10);
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
17
VISUALIZACION/node_modules/htmlnano/test.js
generated
vendored
Executable file
17
VISUALIZACION/node_modules/htmlnano/test.js
generated
vendored
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
// var fs = require('fs');
|
||||
// var htmlnano = require('./index');
|
||||
// var options = {
|
||||
// // removeEmptyAttributes: false, // Disable the module "removeEmptyAttributes"
|
||||
// // collapseWhitespace: 'conservative' // Pass options to the module "collapseWhitespace"
|
||||
// };
|
||||
|
||||
// // var html = fs.readFileSync('./test.html', 'utf8');
|
||||
// var html = `
|
||||
// <script src="../ts/options.ts" />
|
||||
// `;
|
||||
|
||||
// htmlnano.process(html, options).then(function (result) {
|
||||
// // console.log(result.html);
|
||||
// }).catch(function (err) {
|
||||
// // console.error(err);
|
||||
// });
|
||||
Loading…
Add table
Add a link
Reference in a new issue