Multi-Page HTML Repls Throwing Errors

Problem description:
When creating a site with multiple HTML pages (and multiple JavaScript files), the web-view inside Replit is throwing errors about variables already being declared. The problem is that the webview is not destroying previously declared variables in time before it loads the next JavaScript file, making it look like variables are already in existence. An audio-free YouTube video of the problem in action can be found here.

The problem does not happen outside of the Replit preview window. It does not happen if you “pop-out” the project into a normal browser tab and view the console.

Expected behavior:
No errors occur. The expected behaviour happens if you view the site and console outside of the Replit web preview. In a normal browser window, everything is fine.

Actual behavior:
See description, above and this YouTube video I made of the problem.

Steps to reproduce:
Go to this Repl (also linked below) for an example. Run it, stay inside Replit and open the console. Click the hyperlinks to go between pages and watch for the error in the console - it may or may not show up.

Bug appears at this link:

Chrome browser on any OS [Desktop]


Great spot @MrBrash I can replicate this error easily (especially with your HTML guide!). It also shows error for creating i variable at times.