Search code examples
javascriptcodesandbox

How can I use scripts in a static codesandbox template?


I have created a static codesandbox template, but can't seem to get javascript working:

   <html>
     <head>
     <script src="./app.js"></script>
     </head>
     <body>
       <p>Just a test</p>
       <script>console.log("heyyy")</script>
     </body>
    </html>

app.js

 console.log("boink")

The console does not show any console output at all. Are scripts not allowed in static websites without a bundler?


Solution

  • Expanding my comments. It looks like there's a setting which by default causes the console to be cleared. You can change it by clicking the gear icon:

    gear icon

    and then changing this option (if it's enabled it will be green):

    clear console setting

    After turning it off, the console is not cleared anymore for me.