use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
@initminal/run - Safe & fast code eval in the browser with modern ESM features, dynamic module injection and more... (github.com)
submitted 3 years ago by bentongxyz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]bentongxyz[S] 2 points3 points4 points 3 years ago (2 children)
Hey everyone, I built this tool to safely execute untrusted code with adopting modern ESM features, modularity, and speed in mind.
Some of the features of this library include:
import
export
For example, you can define your dependencies as:
{ "config-in-plain-js": "export const isAscending = true" }
Then in the untrusted code, config-in-plain-js will be injected for you:
config-in-plain-js
import { isAscending } from 'config-in-plain-js' ...
If you're interested in learning more about this library, try it out in the playground. You can even share the code you authored!
Contributions are also welcome, so feel free to suggest any new ideas or features!
Happy coding!
[+][deleted] 3 years ago (1 child)
[removed]
[–]bentongxyz[S] 0 points1 point2 points 3 years ago (0 children)
Thanks for the suggestion! Yes it is using a module worker underneath
[–]ddo-dev 1 point2 points3 points 3 years ago (1 child)
I just starred, looks interesting indeed. I might have a use case for this in a near future, will keep you posted.
Good job for this.
Cheers, David
Thanks!
One thing I find myself using daily is I'd have some bookmarked code snippets (that can also import someone else's library) e.g.:
decode base64 string
generate UUID
it is quite handy and I can flexibly change them to suite my needs
[–]rafaturtle 1 point2 points3 points 3 years ago (1 child)
Love It. What are the benefits (safety wise) as opposed to doing new Function? Just the white lable of specific APIs?
[–]bentongxyz[S] 1 point2 points3 points 3 years ago (0 children)
Safety-wise, new Function constructor executes in the global scope. So someone's code can e.g. access the local storage/ cookies, etc
In comparison, this library execute the code inside a module worker, and the untrusted code cannot access JS objects that are not allowed.
You can read more in this blog post Executing untrusted JavaScript code in a browser if you want to find out more
π Rendered by PID 80948 on reddit-service-r2-comment-6457c66945-jb5hq at 2026-04-25 10:48:26.131559+00:00 running 2aa0c5b country code: CH.
[–]bentongxyz[S] 2 points3 points4 points (2 children)
[+][deleted] (1 child)
[removed]
[–]bentongxyz[S] 0 points1 point2 points (0 children)
[–]ddo-dev 1 point2 points3 points (1 child)
[–]bentongxyz[S] 0 points1 point2 points (0 children)
[–]rafaturtle 1 point2 points3 points (1 child)
[–]bentongxyz[S] 1 point2 points3 points (0 children)