JavaScript How to make LiveScript scripts immediately .go() on seen?

(Note: I asked this question on https://github.com/gkz/LiveScript/issues/731 as well)

When I use LiveScript in an html file directly, I have no way to run livescript code immediately on seen. For example;

...
<script src="livescript.js"></script>

<div class="my_target"></div>

<script type="text/ls">
# my livescript code will interact with div.my_target
</script>

<script>
/* a javascript code that will interact with div.my_target
</script>

<script type="text/ls">
# my livescript code does something else
</script>

<script>
    var LiveScript = require("LiveScript");
    LiveScript.go();
</script>

The LiveScript codes both will run, but the LiveScript code that interacts with div.my_target will interact with it AFTER the javascript code does, not BEFORE

If I define

<script>
    var LiveScript = require("LiveScript");
    LiveScript.go();
</script>

part everytime right after a LiveScript code defined, then all LiveScript codes till this definition would run more than one time.

### livescript code 1
### LiveScript.go()
...
### livescript code 2
### LiveScript.go()
...
### livescript code 3
### LiveScript.go()
...

When this code is executed:

  • livescript code 1 will run 3 times, first will run immediately after definition
  • livescript code 2 will run 2 times, first will run immediately after definition
  • livescript code 3 will run 1 time, this will runimmediately after definition

If it would be this way, LiveScript would be used in html more easily and would be used like a native language of web development

...
<script src="livescript.js"></script>
<script>
    var LiveScript = require("LiveScript");
    LiveScript.doSomeMagic_Kaboooommm();
</script>

...
<script type="text/ls">
# my livescript code
</script>

... more html

<script type="text/ls">
# my livescript code
</script>

...

<script type="text/ls">
# my livescript code
</script>
...

Is there anyway to do that?

Answer:1

Are there replacements for the domReady event and the onMutate function in Polymer 0.9? In Firefox the attach event seems to work, but in Chrome the children are not in a proper state at the time of ...

Are there replacements for the domReady event and the onMutate function in Polymer 0.9? In Firefox the attach event seems to work, but in Chrome the children are not in a proper state at the time of ...

I have some route: when('/tvtest/:userid', {templateUrl: 'template/usertv', controller: SomeTest}). which loads some html with emebedded kendo-ui controls: <html> <head> <title&...

I have some route: when('/tvtest/:userid', {templateUrl: 'template/usertv', controller: SomeTest}). which loads some html with emebedded kendo-ui controls: <html> <head> <title&...

  1. kendo treeview angularjs checkbox
  2. kendo treeview angularjs example

I am new to web development and working on web project. In web project I want to show the Loader image on the postback of the page irrespective of the which control caused the postback. Currently I ...

I am new to web development and working on web project. In web project I want to show the Loader image on the postback of the page irrespective of the which control caused the postback. Currently I ...

I see that a lot of projects, e.g., video.js, are now using Grunt.js to build source files. My problem is that when I git clone a project into my repo, run grunt, and then git add/commit/push some ...

I see that a lot of projects, e.g., video.js, are now using Grunt.js to build source files. My problem is that when I git clone a project into my repo, run grunt, and then git add/commit/push some ...