Diff options
Diffstat (limited to '')
| -rw-r--r-- | MANUAL.txt | 2 | |
| -rw-r--r-- | custom/cgitrc | 5 | |
| -rw-r--r-- | source/ui-shared.c | 2 | |
| -rwxr-xr-x | tests/t0005-markup.sh | 5 |
4 files changed, 11 insertions, 3 deletions
@@ -315,6 +315,8 @@ js:: Url which specifies the javascript script document to include in all cgit pages. Default value: "/cgit.js". May be given multiple times, each script URL path is added in the head section of the document in turn. + Each is loaded with defer, so it runs once the page has been parsed, + still in the order given. Setting this to an empty string will disable generation of the link to this file in the head section. diff --git a/custom/cgitrc b/custom/cgitrc index f816f56..569feb4 100644 --- a/custom/cgitrc +++ b/custom/cgitrc @@ -85,8 +85,9 @@ root-desc=a fast webinterface for the git dscm # Value is one or more urls. Default is /cgit.css. css=/cgit.css -# JavaScript document urls included on every page. An empty value disables it. -# Value is one or more urls. Default is /cgit.js. +# JavaScript document urls included on every page, loaded with defer in the +# order given. An empty value disables it. Value is one or more urls. Default +# is /cgit.js. js=/cgit.js # Shortcut icon url for all pages. Value is a url. Default is /favicon.ico. diff --git a/source/ui-shared.c b/source/ui-shared.c index ff691f8..e7b7d88 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -379,7 +379,7 @@ static void emit_js_link(const char *src) html("<script src='"); html_attr(src); - html("'></script>\n"); + html("' defer></script>\n"); } static void add_clone_urls(void (*fn)(const char *), char *urls, char *suffix) diff --git a/tests/t0005-markup.sh b/tests/t0005-markup.sh index e2bf8f3..22ac81c 100755 --- a/tests/t0005-markup.sh +++ b/tests/t0005-markup.sh @@ -120,6 +120,11 @@ test_expect_success 'the page background is the same everywhere it is set' ' test_cmp expect actual ' +test_expect_success 'the script waits for the page instead of holding it up' ' + hooks "hooks/" >tmp && + grep "<script src=./cgit.js. defer></script>" tmp +' + # The rest of the hooks need a tag, a symlink, a submodule, a trailer, a lone # carriage return, clone urls, an empty repository and a second page of # repositories, so they get a commit and a config of their own after the checks |
