"I'd never do this" sounds like a challenge 😈

Brad at ultimatumlabs.com posted about a thought experiment.

A script like this in a page could be executed by a Gemini client:

### My Dynamic Gemini Page
``` script=JS
print("The time is: " + new Date());
```
Thanks for stopping by!

This feels like going against the spirit of Gemini in one way. We're on the small web to get away from the madness that begins with one small script and ends with megabytes of script per page. You can see why Brad said

To be clear, this is only a thought experiment.

But...

On the other hand, the rendering of Gemtext pages is up to the client. It's within the spirit of Gemini that clients should deal with page content however seems best. For example, several clients will in-line images on a page.

So I had a go. It helped that I already had a script runner that was easily plugged in. I can now display the date and time using the script above, and it updates if I refresh the page.

I couldn't think of anything useful to do in a script, but I could get it to interact with the user:

``` script=JS
if ( confirm( 'Do you like JavaScript?' ) )
print( 'Some content for a JavaScript fan goes here...' )
else
print( 'This content is for JavaScript dislikers.' )
```

One fun thing: security issues. The script runner was expecting the scripts to be written by the user, so it allowed, for example, fetching of web content. Oh dear. These scripts would be written by some random person off the internet. Probably best to disable fetching anything external. Even if the fetched content couldn't do much harm inside the script, it would still allow user tracking. And you could fetch local file URLs and send the content to your nefarious server for reasons of badness.

I did it just to see how hard it was (not very) and what the implications would be (nothing too bad if sandboxed, but also nothing too useful). I won't be releasing this feature.

#gemtext
#Jemi
back to gemlog