Search code examples
javascripthtmlcoffeescriptlivescript

How to hack LiveScript in order to link a separate file in html


We could include separate coffee-script file in html with:

<script type="text/coffeescript" src="/static/webpage.coffee"></script>

But if we want to use LiveScript in browser, they say:

If you use this, your LiveScript scripts must be inline (not linked to with the src attribute), be placed after the included livescript.js file, and the script tags must have the attribute type="text/ls".

I need exact same include technique we used to use for coffee-script or Javascript. So, is there anyone give me a tip to start hacking?


Solution

  • Looking at LiveScript.go() in src/browser.ls (browser/livescript.js) it is apparent that external files are actually supported. Indeed, the following worked for me:

    <head>
        <script src="livescript-min.js"></script>
        <script type="text/ls" src="script.ls"></script>
        <script>
            require('LiveScript').go();
        </script>
    </head>