Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit e7aec13

Browse files
authored
Merge pull request #41 from shinsenter/develop
Fixed bug: defer function not found
2 parents ff9b9a3 + 4e27c26 commit e7aec13

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/DeferOptimizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected function addDeferJs()
142142
static::ATTR_ID => 'defer-js',
143143
]);
144144

145-
$this->head->appendChild($script_tag);
145+
$this->head->insertBefore($script_tag, $the_anchor);
146146
$script_tag = null;
147147
}
148148

@@ -167,7 +167,7 @@ protected function addDeferJs()
167167
if (!empty($script)) {
168168
$script_tag = $this->createNode(static::SCRIPT_TAG, trim($script), [static::ATTR_ID => 'defer-script']);
169169

170-
$this->head->appendChild($script_tag);
170+
$this->head->insertBefore($script_tag, $the_anchor);
171171
$script_tag = null;
172172
}
173173

0 commit comments

Comments
 (0)