Is it bad to have script tag inside div?

html, javascript

Solution

It is perfectly ok to place the `<script>` tag anywhere in the body of the document.

From here,

The SCRIPT element places a script within a document. This element may appear any number of times in the HEAD or BODY of an HTML document.

However, whenever a `<script>` tag occurs, it pauses the parsing of the code till the script gets loaded, and executed.

Problem

What is bad about having a `<script>` tag inside `<div>` inside `<body>`? I'm dynamically updating a `<div>` to reload a JavaScript code inside a `<div>`. Are there any issues to worry about ? Edit As @Bergi insisted on seeing the code. Here it is(see below). This `div` (along with other `div`(s) containing presentation HTML elements) are updated via AJAX. This `script` inside `div` contains maps to do processing of newly loaded HTML elements on page with raw data. ``` <div> <script type="text/javascript"> var namesMap = <dynamic string from server here>; var addressesMap = <dynamic string from server here>; </script> </div> ```

Original source

Related problems