diff --git a/application/webpage.class.inc.php b/application/webpage.class.inc.php index 82f7a2455..29620f226 100644 --- a/application/webpage.class.inc.php +++ b/application/webpage.class.inc.php @@ -671,31 +671,7 @@ class WebPage implements Page echo "".htmlentities($this->s_title, ENT_QUOTES, 'UTF-8')."\n"; echo $this->get_base_tag(); - $this->output_dict_entries(); - - foreach ($this->a_linked_scripts as $s_script) - { - // Make sure that the URL to the script contains the application's version number - // so that the new script do NOT get reloaded from the cache when the application is upgraded - if (strpos($s_script, '?') === false) - { - $s_script .= "?t=".utils::GetCacheBusterTimestamp(); - } - else - { - $s_script .= "&t=".utils::GetCacheBusterTimestamp(); - } - echo "\n"; - } - if (count($this->a_scripts) > 0) - { - echo "\n"; - } + // First put stylesheets so they can be loaded before browser interprets JS files, otherwise visual glitch can occur. foreach ($this->a_linked_stylesheets as $a_stylesheet) { if (strpos($a_stylesheet['link'], '?') === false) @@ -717,6 +693,7 @@ class WebPage implements Page } } + // Then inline styles if (count($this->a_styles) > 0) { echo "\n"; } + + // Favicon if (class_exists('MetaModel') && MetaModel::GetConfig()) { echo "\n"; } + + // Dict entries for JS + $this->output_dict_entries(); + + // JS files + foreach ($this->a_linked_scripts as $s_script) + { + // Make sure that the URL to the script contains the application's version number + // so that the new script do NOT get reloaded from the cache when the application is upgraded + if (strpos($s_script, '?') === false) + { + $s_script .= "?t=".utils::GetCacheBusterTimestamp(); + } + else + { + $s_script .= "&t=".utils::GetCacheBusterTimestamp(); + } + echo "\n"; + } + + // JS inline scripts + if (count($this->a_scripts) > 0) + { + echo "\n"; + } + echo "\n"; echo "\n"; echo self::FilterXSS($this->s_content);