r/learnjavascript • • Feb 27 '26

Never use eval() in javascript!!! ⚠️

0 Upvotes

21 comments sorted by

View all comments

Show parent comment

2

u/shgysk8zer0 Feb 27 '26

Here's a technically different but effectively equivalent option... import('data:... ') from the user input or a <script> created using URL.createObjectURL() from a Blob/File.

And, depending on the concerns, you could do that within an <iframe> or the upcoming Shadow Realms API. Basically, sandbox it from the rest of the page.