JQuery to load Javascript file dynamically
Yes, use getScript instead of document.write – it will even allow for a callback once the file loads. You might want to check if TinyMCE is defined, though, before including it (for subsequent calls to ‘Add Comment’) so the code might look something like this: $(‘#add_comment’).click(function() { if(typeof TinyMCE == “undefined”) { $.getScript(‘tinymce.js’, function() { … Read more