Experimenting with a new technique where I divide my code into separate files to create multiple HTML pages instead of one large one. Using ajax to load them and then setting the content as innerHTML to a parent div results in clean code that works well in modern browsers. However, I recently discovered that when an external page contains a <script>
tag, the JavaScript within it is not parsed or loaded into the parent page's JavaScript context, causing methods and variables from these external snippets to be missing.
I found a workaround by manually reading the script tag's content and using eval()
on it, which solves the issue. Nevertheless, I'm wondering if there is a more native way to include the script in these external files, or if this approach is the only option available for achieving my goals.
Thanks in advance