Skip to content
This repository was archived by the owner on Jul 21, 2019. It is now read-only.

Commit a2ee444

Browse files
committed
improves template rendering performance
reduce the overall rendering time by ~75% via the following: - cache the entirely-static footer partial - eliminate looping over all talks in speaker page - eliminate looping over all speakers in talk page
1 parent 28e6c40 commit a2ee444

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

layouts/_default/baseof.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{{- end -}}
3636
</div>
3737
</div>
38-
{{- partial "footer.html" . -}}
38+
{{- partialCached "footer.html" . -}}
3939
{{- partial "footer_scripts.html" . -}}
4040
</body>
4141
</html>

layouts/speaker/single.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ <h2 class="speaker-page">{{ .Title }}</h2>
1616
<h3>{{ .Title }} at {{ $e.city }} {{$e.year}}</h3>
1717
<ul class="list-group">
1818
{{- $.Scratch.Set "speaker" .File.BaseFileName -}}
19-
{{- range where $.Site.Pages "Type" "talk" -}}
20-
{{- if eq (index (split (.Permalink | relURL) "/") 2) $e.name -}}
19+
20+
{{- $p := $.Site.GetPage (printf "events/%s/program/%s" $e.name ($.Scratch.Get "speaker")) -}}
21+
{{- if $p -}}
22+
{{- with $p -}}
2123
<!-- Now we can display stuff! -->
2224
{{- range .Params.speakers -}}
2325
{{- if eq . ($.Scratch.Get "speaker") -}}
@@ -28,12 +30,10 @@ <h3>{{ .Title }} at {{ $e.city }} {{$e.year}}</h3>
2830
<a href = "{{ .Permalink | absURL }}" class= "list-group-item list-group-item-action">{{ .Title }}</a>
2931
{{ $.Scratch.Set "display" "false" }}
3032
{{- end -}}
31-
{{- end -}} <!-- end if eq $talk_slug $event_slug -->
32-
{{- end -}} <!-- end range where $.Site.Pages "Type" "speaker" -->
33+
{{- end -}} <!-- end with -->
34+
{{- end -}} <!-- end if $p -->
3335
</ul>
3436
</div>
35-
<!-- </div>
36-
</div> -->
3737
</div>
3838
<div class = "col-md-3 offset-md-1">
3939
{{- if isset .Params "image" -}}

layouts/talk/single.html

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,10 @@ <h2 class="talk-page">Speaker</h2>
112112

113113
{{- range .Params.speakers -}}
114114
{{- $.Scratch.Set "speakername" . -}}
115-
{{- range where $.Site.Pages "Type" "speaker" -}}
116-
{{- if eq (index (split (.Permalink | relURL) "/") 2) $e.name -}}
117-
{{- if eq .File.BaseFileName ($.Scratch.Get "speakername") -}}
118-
<a href = "{{ (printf "events/%s/speakers/%s" $e.name ($.Scratch.Get "speakername")) | absURL}}">
119-
{{- if isset .Params "image" -}}
115+
{{- $p := $.Site.GetPage (printf "events/%s/speakers/%s" $e.name ($.Scratch.Get "speakername")) -}}
116+
{{- if $p -}}
117+
{{- with $p -}}
118+
{{- if isset .Params "image" -}}
120119
{{- if ne .Params.image "" -}}
121120
<img src = "{{ (printf "events/%s/speakers/%s" $e.name .Params.image) | absURL }}" class="img-fluid" alt="{{ $.Scratch.Get "speakername" }}"/><br /><br />
122121
{{- end -}}
@@ -167,8 +166,7 @@ <h4 class="talk-page"><a href = "{{ (printf "events/%s/speakers/%s" $e.name ($.S
167166
{{- end -}}
168167

169168
{{- end -}}
170-
{{- end -}} <!-- end range where $.Site.Pages "Type" "speaker" -->
171-
{{- end -}}
169+
{{- end -}}<!-- end with -->
172170
{{- else -}}<!-- now show the old stuff -->
173171
<h2 class="talk-page">Speaker</h2>
174172
{{- range $fname, $s := index .Site.Data.speakers (print (chomp $e.year)) (substr $e.name 5) -}}

0 commit comments

Comments
 (0)