I have the JavaScript file name in the database, and I have a jQuery ajax script on the clientside page which returns JSON data containing the JavaScript filenames.
I’m having to do awful stuff like this:
$( "head" ).append( "<scr" + "ipt type='text/javascript' src='js/" + widget_data.d[i].script + "'></scr" + "ipt>" );
Is there are recommended/preferred way of dynamically adding scripts to a HTML pages head section?
You are using jQuery, the easiest way is to use
$.getScript(), like in this example: http://www.mkyong.com/jquery/how-to-load-javascript-at-runtime-with-jquery/DOCS: getScript()