0

I would like to add a defer attribute to a script tab in hiccup.

But things like [:script {:src "main.js" :defer}] return an error, and forms like [:script {:src "main.js"} :defer] insert "defer" in the middle of the script opening and closing tags.

Does anybody know how can i get something that translate to <script src="main.js" defer></script> ?

xav
  • 4,101
  • 5
  • 26
  • 32

1 Answers1

3

You need to add a value for a :defer map key:

[:script {:src "main.js" :defer true}]

It should generate:

<script src="main.js" defer="true"></script>

which is equivalent to:

<script src="main.js" defer></script>

Piotrek Bzdyl
  • 12,965
  • 1
  • 31
  • 49