Skip to content

Commit 1df3325

Browse files
committed
add core fileclient script before others
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 37e3115 commit 1df3325

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

core/Listener/BeforeTemplateRenderedListener.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public function handle(Event $event): void {
6262
Util::addTranslations('core');
6363

6464
if ($event->getResponse()->getRenderAs() !== TemplateResponse::RENDER_AS_ERROR) {
65-
Util::addScript('core', 'files_fileinfo');
66-
Util::addScript('core', 'files_client');
67-
Util::addScript('core', 'merged-template-prepend');
65+
Util::addScript('core', 'merged-template-prepend', 'core', true);
66+
Util::addScript('core', 'files_client', 'core', true);
67+
Util::addScript('core', 'files_fileinfo', 'core', true);
6868

6969

7070
// If installed and background job is set to ajax, add dedicated script

lib/public/Util.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ public static function addStyle($application, $file = null) {
169169
* @param string $application
170170
* @param string|null $file
171171
* @param string $afterAppId
172+
* @param bool $prepend
172173
* @since 4.0.0
173174
*/
174-
public static function addScript(string $application, string $file = null, string $afterAppId = 'core'): void {
175+
public static function addScript(string $application, string $file = null, string $afterAppId = 'core', bool $prepend = false): void {
175176
if (!empty($application)) {
176177
$path = "$application/js/$file";
177178
} else {
@@ -194,7 +195,11 @@ public static function addScript(string $application, string $file = null, strin
194195
self::$scriptDeps[$application]->addDep($afterAppId);
195196
}
196197

197-
self::$scripts[$application][] = $path;
198+
if ($prepend) {
199+
array_unshift(self::$scripts[$application], $path);
200+
} else {
201+
self::$scripts[$application][] = $path;
202+
}
198203
}
199204

200205
/**

0 commit comments

Comments
 (0)