In the tests I have run (html with bad javascript tag), the toinsert element is actually attached to the DOM *before* the error is raised (the attaching to the document is what results in the javascript actually executing, which in turn results in the exception).  I suppose it is technically possible that the element appending would fail, but I haven't seen it happen, and might require a jQuery bug.