Is it possible to inline built javascript?

When using Javascript Building (JavaScript Building | Hugo), is it possible to dump the built javascript to the template file (i.e. to avoid a file request at runtime), rather than just getting a reference to the built file to load at runtime?

Thanks!

Yes.

Instead of this:

<script type="text/javascript" src="{{ $js.RelPermalink }}"></script>

Do this:

<script>{{ $js.Content | safeJS }}</script>
3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.