diff --git a/basis/html/templates/chloe/chloe-docs.factor b/basis/html/templates/chloe/chloe-docs.factor
index af03e8e1b9..c38cf0ac4c 100644
--- a/basis/html/templates/chloe/chloe-docs.factor
+++ b/basis/html/templates/chloe/chloe-docs.factor
@@ -88,6 +88,8 @@ $nl
{ { $snippet "t:write-title" } "Renders the child's title. Intended for use in a child template." }
{ { $snippet "t:style" } { "Adds CSS markup from the file named by the " { $snippet "t:include" } " attribute. Intended for use in a child template." } }
{ { $snippet "t:write-style" } "Renders the children's CSS markup. Intended for use in a master template." }
+ { { $snippet "t:script" } { "Adds JS from the file named by the " { $snippet "t:include" } " attribute. Intended for use in a child template." } }
+ { { $snippet "t:write-script" } "Renders the children's JS. Intended for use in a master template." }
{ { $snippet "t:atom" } { "Adds an Atom feed link. The attributes are the same as the " { $snippet "t:link" } " tag. Intended for use in a child template. (*)" } }
{ { $snippet "t:write-atom" } "Renders the children's list of Atom feed links. Intended for use in a master template. (*)" }
{ { $snippet "t:call-next-template" } "Calls the next child template from a master template." }
diff --git a/basis/html/templates/chloe/chloe.factor b/basis/html/templates/chloe/chloe.factor
index 0cd639d805..89feebecd0 100644
--- a/basis/html/templates/chloe/chloe.factor
+++ b/basis/html/templates/chloe/chloe.factor
@@ -36,6 +36,19 @@ CHLOE: write-style
[XML XML]
] [xml-code] ;
+CHLOE: script
+ dup "include" optional-attr [
+ utf8 file-contents [ add-script ] [code-with]
+ ] [
+ compile-children>string [ add-script ] [code]
+ ] ?if ;
+
+CHLOE: write-script
+ drop [
+ get-script
+ [XML XML]
+ ] [xml-code] ;
+
CHLOE: even
[ "index" value even? swap when ] process-children ;
diff --git a/basis/html/templates/templates.factor b/basis/html/templates/templates.factor
index 4187205495..9fe3b1bb7d 100644
--- a/basis/html/templates/templates.factor
+++ b/basis/html/templates/templates.factor
@@ -59,6 +59,18 @@ SYMBOL: style
: write-style ( -- )
get-style write ;
+SYMBOL: script
+
+: add-script ( string -- )
+ "\n" script get push-all
+ script get push-all ;
+
+: get-script ( -- string )
+ script get >string ;
+
+: write-script ( -- )
+ get-script write ;
+
SYMBOL: atom-feeds
: add-atom-feed ( title url -- )
@@ -91,6 +103,7 @@ M: f call-template* drop call-next-template ;
[
title [ [ ] unless* ] change
style [ [ SBUF" " clone ] unless* ] change
+ script [ [ SBUF" " clone ] unless* ] change
atom-feeds [ V{ } like ] change
[