Ver Fonte

prevent concatenating scripts and removing ones with src defined

Gildas há 7 anos atrás
pai
commit
d900d97fa8
1 ficheiros alterados com 2 adições e 3 exclusões
  1. 2 3
      lib/single-file/modules/html-minifier.js

+ 2 - 3
lib/single-file/modules/html-minifier.js

@@ -132,8 +132,7 @@ this.htmlMinifier = this.htmlMinifier || (() => {
 		removeEmptyAttributes,
 		removeRedundantAttributes,
 		compressJSONLD,
-		node => mergeElements(node, "style", (node, previousSibling) => node.parentElement && node.parentElement.tagName == "HEAD" && node.media == previousSibling.media && node.title == previousSibling.title),
-		node => mergeElements(node, "script", (node, previousSibling) => node.parentElement && node.parentElement.tagName == "HEAD" && ((!node.type || node.nodeType == "text/javascript") && (!previousSibling.type || previousSibling.nodeType == "text/javascript")))
+		node => mergeElements(node, "style", (node, previousSibling) => node.parentElement && node.parentElement.tagName == "HEAD" && node.media == previousSibling.media && node.title == previousSibling.title)
 	];
 
 	return {
@@ -255,7 +254,7 @@ this.htmlMinifier = this.htmlMinifier || (() => {
 	}
 
 	function removeEmptyInlineElements(doc) {
-		doc.querySelectorAll("style, script, noscript").forEach(element => {
+		doc.querySelectorAll("style, script:not([src]), noscript").forEach(element => {
 			if (!element.textContent.trim()) {
 				element.remove();
 			}