From d16e34c736676256b7cd3ea12797313dc1332fc3 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Antoine=20Beaupr=C3=A9?=
Date: Mon, 6 Nov 2017 14:15:22 -0500
Subject: [PATCH] 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*
]*>)!$1.include_javascript($params{page})!em)) {
+ if (! ($params{content}=~s!^(\s* 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!^(]*>)!$1.include_javascript($params{page})!em)) {
+ if (! ($params{content}=~s!^(\s*]*>)!include_javascript($params{page}).$1!em)) {
# no 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!(\s*)
!$1!g) {
$params{content}=~s///g;
- if (! ($params{content}=~s!^(]*>)!$1.include_javascript($params{page})!em)) {
+ if (! ($params{content}=~s!^(\s*]*>)!include_javascript($params{page}).$1!em)) {
# no tag, probably in preview mode
- $params{content}=include_javascript(undef).$params{content};
+ $params{content}=$params{content}.include_javascript(undef);
}
}
return $params{content};
--
2.39.5