alex-009
alex-009•2w ago

Can I "execute" javascript in deno?

Let's say there is a line like this
<script nonce="73fa3ef1f4ac4682af1cfcb8b3563a89">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5B5TH8ZJ');</script>
<script nonce="73fa3ef1f4ac4682af1cfcb8b3563a89">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5B5TH8ZJ');</script>
and I'm able to get the innerText (...) can I execute the javascript in deno?
2 Replies
bartlomieju
bartlomieju•2w ago
No, this script uses DOM API which are not available in Deno
Doctor 🤖
Doctor 🤖•2w ago
Yes, if the script only uses APIs available in Deno globalThis.document doesn't exist in Deno though