Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 1913bf8

Browse files
ausileofeyer
authored andcommitted
Fix the async flag handling (see #7382)
1 parent e2120df commit 1913bf8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: system/modules/core/library/Contao/Controller.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -1948,18 +1948,26 @@ public static function replaceDynamicScriptTags($strBuffer)
19481948
if (!empty($GLOBALS['TL_JAVASCRIPT']) && is_array($GLOBALS['TL_JAVASCRIPT']))
19491949
{
19501950
$objCombiner = new \Combiner();
1951+
$objCombinerAsync = new \Combiner();
19511952

19521953
foreach (array_unique($GLOBALS['TL_JAVASCRIPT']) as $javascript)
19531954
{
19541955
$options = \String::resolveFlaggedUrl($javascript);
19551956

19561957
if ($options->static)
19571958
{
1958-
$objCombiner->add($javascript, filemtime(TL_ROOT . '/' . $javascript));
1959+
if ($options->async)
1960+
{
1961+
$objCombinerAsync->add($javascript, filemtime(TL_ROOT . '/' . $javascript));
1962+
}
1963+
else
1964+
{
1965+
$objCombiner->add($javascript, filemtime(TL_ROOT . '/' . $javascript));
1966+
}
19591967
}
19601968
else
19611969
{
1962-
$strScripts .= \Template::generateScriptTag(static::addStaticUrlTo($javascript), $blnXhtml) . "\n";
1970+
$strScripts .= \Template::generateScriptTag(static::addStaticUrlTo($javascript), $blnXhtml, $options->async) . "\n";
19631971
}
19641972
}
19651973

@@ -1968,6 +1976,11 @@ public static function replaceDynamicScriptTags($strBuffer)
19681976
{
19691977
$strScripts = \Template::generateScriptTag($objCombiner->getCombinedFile(), $blnXhtml) . "\n" . $strScripts;
19701978
}
1979+
1980+
if ($objCombinerAsync->hasEntries())
1981+
{
1982+
$strScripts = \Template::generateScriptTag($objCombinerAsync->getCombinedFile(), $blnXhtml, true) . "\n" . $strScripts;
1983+
}
19711984
}
19721985

19731986
// Add the internal <head> tags

0 commit comments

Comments
 (0)