Search code examples
javascripttapestry

Tapestry 4.1 - using a Script component with an external js


Is it possible to use a @Script component to render a script tag pointing to a js file hosted on a different server?

Basically, I need to inject a script tag such as:

<script src="http://otherserver.com/script.js"></script>

but I need to have it render in the head, or at least before other tapestry scripts are rendered.

Thanks, Paul.


Solution

  • If you're using the Shell component , it's easy:

    Shell.get(cycle).includeAdditionalContent( myHtmlForHead );
    

    Or write a simple component that does that and reuse it in your templates.