Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #605 from willrossi/trac6648
FIX: insert javascript requirements before the first inline script.
  • Loading branch information
chillu committed Jul 5, 2012
2 parents 4b9ccab + 9f6eeb4 commit 2deb5d6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions view/Requirements.php
Expand Up @@ -695,9 +695,10 @@ function includeInHTML($templateFile, $content) {
// We put script tags into the body, for performance.
// If your template already has script tags in the body, then we put our script
// tags just before those. Otherwise, we put it at the bottom.
$p1 = strripos($content, '<script');
$p2 = stripos($content, '<body');
if($p1 !== false && $p1 > $p2) {
$p1 = stripos($content, '<script', $p2);

if($p1 !== false) {
$content = substr($content,0,$p1) . $jsRequirements . substr($content,$p1);
} else {
$content = preg_replace("/(<\/body[^>]*>)/i", $jsRequirements . "\\1", $content);
Expand Down

0 comments on commit 2deb5d6

Please sign in to comment.