1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:04:44 -07:00

godoc: add the defer attribute to script tags

This allows the scripts to be downloaded concurrently as the
body is being parsed.

Deferred scripts are executed in order and only after the entire
document has been loaded. So essentially the entire effect remains same
but we reduce the network download time.

Also, CL 90396 missed out updating static.go. Packaging the change along
with this.

Change-Id: Ia850bd50b49f2a9e0e4fbc29617858ab0fa8a0b9
Reviewed-on: https://go-review.googlesource.com/100295
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Agniva De Sarker 2018-03-13 15:21:37 +05:30 committed by Andrew Bonventre
parent c41d143952
commit 5ad4d95e58
2 changed files with 22 additions and 28 deletions

View File

@ -14,7 +14,16 @@
<link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" /> <link rel="search" type="application/opensearchdescription+xml" title="godoc" href="/opensearch.xml" />
{{end}} {{end}}
<link rel="stylesheet" href="/lib/godoc/jquery.treeview.css"> <link rel="stylesheet" href="/lib/godoc/jquery.treeview.css">
<script type="text/javascript">window.initFuncs = [];</script> <script>window.initFuncs = [];</script>
<script src="/lib/godoc/jquery.js" defer></script>
<script src="/lib/godoc/jquery.treeview.js" defer></script>
<script src="/lib/godoc/jquery.treeview.edit.js" defer></script>
{{if .Playground}}
<script src="/lib/godoc/playground.js" defer></script>
{{end}}
{{with .Version}}<script>var goVersion = {{printf "%q" .}};</script>{{end}}
<script src="/lib/godoc/godocs.js" defer></script>
</head> </head>
<body> <body>
@ -103,18 +112,6 @@ and code is licensed under a <a href="/LICENSE">BSD license</a>.<br>
</div><!-- .container --> </div><!-- .container -->
</div><!-- #page --> </div><!-- #page -->
<!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
<script type="text/javascript" src="/lib/godoc/jquery.js"></script>
<script type="text/javascript" src="/lib/godoc/jquery.treeview.js"></script>
<script type="text/javascript" src="/lib/godoc/jquery.treeview.edit.js"></script>
{{if .Playground}}
<script type="text/javascript" src="/lib/godoc/playground.js"></script>
{{end}}
{{with .Version}}<script>var goVersion = {{printf "%q" .}};</script>{{end}}
<script type="text/javascript" src="/lib/godoc/godocs.js"></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long