If I'm not mistaken, embedded scripts pause the parsing of html in order to run, yet I see scripts that reference the id of an html element that appears after the script itself. How is the script able to "find" that element by id, if the parser has presumably not yet reached that element yet?
For example, many sites using Datatables runs this in the head of the html file, far before the table corresponding to that id appears.
$(document).ready( function () {
$('#table_id').DataTable();
} );