https://github.com/rads/squint-browser
Run ClojureScript in script tags without a build step using the squint compiler.
https://github.com/rads/squint-browser
Last synced: 9 months ago
JSON representation
Run ClojureScript in script tags without a build step using the squint compiler.
- Host: GitHub
- URL: https://github.com/rads/squint-browser
- Owner: rads
- License: mit
- Created: 2024-05-31T21:09:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-31T23:02:39.000Z (over 1 year ago)
- Last Synced: 2025-02-07T17:11:20.316Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# squint-browser
Run ClojureScript in `` tags without a build step using the [squint](https://github.com/squint-cljs/squint) compiler.
[Click here for an example.](https://rads.github.io/squint-browser/)
## Usage
Add the following code at the end of the `<body>` tag:
```html
<script type="module">
import squintBrowser from 'https://cdn.jsdelivr.net/gh/rads/squint-browser@v0.0.2/squint-browser.min.js';
squintBrowser();
```
Now you can write inline ClojureScript using script tags. Make sure to put them _before_ the other script we added:
```html
(println "Hello world!")
```
### Options
You can pass in options to the `squintBrowser` function:
```html
import squintBrowser from 'https://cdn.jsdelivr.net/gh/rads/squint-browser@v0.0.2/squint-browser.min.js';
squintBrowser({
// Cache compiled scripts using getItem and setItem. If all scripts are
// cached, the compiler won't get loaded at all and no compilation will
// occur. Note that if you use persistent storage, you need to clean up old
// cache entries yourself or the cache will grow indefinitely.
cache: localStorage,
// Override the function to find source scripts.
scripts: async () => {
return document.querySelectorAll('script[type="application/clojurescript"]');
}
// Override the default import map used when loading scripts.
// This can be used to override the squint-cljs compiler version.
importMap: {
imports: {
"squint-cljs/": "https://esm.run/squint-cljs/"
}
}
});
```