Skip to content

Commit e22fb4e

Browse files
committed
Removed auto move scripts to the bottom. It will be an option in the future.
1 parent e15c0b2 commit e22fb4e

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/HTMLServerComponentsCompiler.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,27 @@ public function process($html)
8383
$componentBodyChildrenCount = $componentBodyElement->childNodes->length;
8484

8585
// keep scripts at the bottom
86-
$scriptElementsMovedIndexes = [];
87-
for ($j = $componentBodyChildrenCount - 1; $j >= 0; $j--) {
88-
$componentChild = $componentBodyElement->childNodes->item($j);
89-
if ($componentChild instanceof DOMText) {
90-
continue;
91-
}
92-
if ($componentChild instanceof DOMElement && $componentChild->tagName === 'script') {
93-
$componentChildAttributes = $this->getDOMElementAttributes($componentChild);
94-
if (!isset($componentChildAttributes['type']) || $componentChildAttributes['type'] === '' || $componentChildAttributes['type'] === 'text/javascript') {
95-
$domBodyElement->appendChild($domDocument->importNode($componentChild, true));
96-
$scriptElementsMovedIndexes[$j] = 1;
97-
}
98-
} else {
99-
break;
100-
}
101-
}
86+
// $scriptElementsMovedIndexes = [];
87+
// for ($j = $componentBodyChildrenCount - 1; $j >= 0; $j--) {
88+
// $componentChild = $componentBodyElement->childNodes->item($j);
89+
// if ($componentChild instanceof DOMText) {
90+
// continue;
91+
// }
92+
// if ($componentChild instanceof DOMElement && $componentChild->tagName === 'script') {
93+
// $componentChildAttributes = $this->getDOMElementAttributes($componentChild);
94+
// if (!isset($componentChildAttributes['type']) || $componentChildAttributes['type'] === '' || $componentChildAttributes['type'] === 'text/javascript') {
95+
// $domBodyElement->appendChild($domDocument->importNode($componentChild, true));
96+
// $scriptElementsMovedIndexes[$j] = 1;
97+
// }
98+
// } else {
99+
// break;
100+
// }
101+
// }
102102

103103
for ($j = 0; $j < $componentBodyChildrenCount; $j++) {
104-
if (!isset($scriptElementsMovedIndexes[$j])) {
105-
$component->parentNode->insertBefore($domDocument->importNode($componentBodyElement->childNodes->item($j), true), $component);
106-
}
104+
//if (!isset($scriptElementsMovedIndexes[$j])) {
105+
$component->parentNode->insertBefore($domDocument->importNode($componentBodyElement->childNodes->item($j), true), $component);
106+
//}
107107
}
108108

109109
// add head elements

0 commit comments

Comments
 (0)