aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorAntoine Beaupré <anarcat@debian.org>2017-11-06 14:15:22 -0500
committerSimon McVittie <smcv@debian.org>2019-02-03 17:01:55 +0000
commitd16e34c736676256b7cd3ea12797313dc1332fc3 (patch)
tree8221054fb81e29b1dd853ad2e2613b784a278e0b /IkiWiki
parentaa063aeb337271577fc426dc32b26c1ca87807e5 (diff)
downloadikiwiki-d16e34c736676256b7cd3ea12797313dc1332fc3.tar
ikiwiki-d16e34c736676256b7cd3ea12797313dc1332fc3.tar.gz
append javascript after CSS
Javascript resources should be presented to browsers after CSS, and "after the fold" (ATF) according to the best practices: https://developers.google.com/speed/docs/insights/mobile#PutStylesBeforeScripts This change allows the browser to download Javascript files in parallel, by including Javascript on the *closing* </body> tag instead of the opening tag. We also improve the regex to tolerate spaces before the body tag, as some templates have (proper) indentation for the tag.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/recentchangesdiff.pm4
-rw-r--r--IkiWiki/Plugin/relativedate.pm4
-rw-r--r--IkiWiki/Plugin/toggle.pm4
3 files changed, 6 insertions, 6 deletions
diff --git a/IkiWiki/Plugin/recentchangesdiff.pm b/IkiWiki/Plugin/recentchangesdiff.pm
index eb358be67..0093c655e 100644
--- a/IkiWiki/Plugin/recentchangesdiff.pm
+++ b/IkiWiki/Plugin/recentchangesdiff.pm
@@ -60,9 +60,9 @@ sub pagetemplate (@) {
sub format (@) {
my %params=@_;
- if (! ($params{content}=~s!^(<body[^>]*>)!$1.include_javascript($params{page})!em)) {
+ if (! ($params{content}=~s!^(\s*</body[^>]*>)!include_javascript($params{page}).$1!em)) {
# no <body> tag, probably in preview mode
- $params{content}=include_javascript(undef).$params{content};
+ $params{content}=$params{content}.include_javascript(undef);
}
return $params{content};
}
diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm
index 4ae0be861..083966ad2 100644
--- a/IkiWiki/Plugin/relativedate.pm
+++ b/IkiWiki/Plugin/relativedate.pm
@@ -26,9 +26,9 @@ sub getsetup () {
sub format (@) {
my %params=@_;
- if (! ($params{content}=~s!^(<body[^>]*>)!$1.include_javascript($params{page})!em)) {
+ if (! ($params{content}=~s!^(\s*</body[^>]*>)!include_javascript($params{page}).$1!em)) {
# no <body> tag, probably in preview mode
- $params{content}=include_javascript(undef).$params{content};
+ $params{content}=$params{content}.include_javascript(undef);
}
return $params{content};
}
diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm
index af4d2ba3a..eea6e8861 100644
--- a/IkiWiki/Plugin/toggle.pm
+++ b/IkiWiki/Plugin/toggle.pm
@@ -68,9 +68,9 @@ sub format (@) {
if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">\s*)</div>!$1!g) {
$params{content}=~s/<div class="toggleableend">//g;
- if (! ($params{content}=~s!^(<body[^>]*>)!$1.include_javascript($params{page})!em)) {
+ if (! ($params{content}=~s!^(\s*</body[^>]*>)!include_javascript($params{page}).$1!em)) {
# no <body> tag, probably in preview mode
- $params{content}=include_javascript(undef).$params{content};
+ $params{content}=$params{content}.include_javascript(undef);
}
}
return $params{content};