This project exposes the Small Clojure Interpreter in the browser in such a way that you can use it with the script tag.
This project is currently experimental and breaking changes are bound to happen. Feedback is welcome on Github.
You can get a copy of sci-script-tag.js here. If you want a pinned version of sci-script-tag.js, your best bet is to download your own copy and host it yourself.
<head> <script src="https://borkdude.github.io/sci-script-tag/js/sci-script-tag.js" type="application/javascript"></script> <script type="application/x-sci"> (defn my-alert [] (js/alert "alert!")) </script> </head> <body> <button onclick="user.myAlert()"> Click me </button> </body>
<script src="https://borkdude.github.io/sci-script-tag/js/sci-script-tag-plugin-reagent.js" type="application/javascript"></script> <script type="application/x-sci"> (require '[reagent.core :as r] '[reagent.dom :as rdom]) (def state (r/atom {:clicks 0})) (defn my-component [] [:div [:p "Clicks: " (:clicks @state)] [:p [:button {:on-click #(swap! state update :clicks inc)} "Click me!"]]]) (rdom/render [my-component] (.getElementById js/document "app")) </script>