Reusing a dialog, Dialog performance

Reusing a dialog, Dialog performance


I'm looking into using Dialog as a replacement for simple alerts, but
at least the way I'm currently doing it, it's very slow. The target
dom object is just an empty div with an ID. Preliminary code is this:
----
jQuery.fn.alert = function(msg, title)
{
    $('#dlg').html('<pre><span>' + msg + '</span></pre>').dialog
    (
        {
            title: title ? title : 'Application Alert',
            buttons: {OK: function(){$(this).dialog('close');}},
            modal: true,
            overlay: {background: '#000', opacity: 0.1},
            width: 450,
            height: 250
        }
    );
};
----
The reason I'm creating the dlg every time is that other code will use
this same div with different options. Is there some way to change
options dynamically once the dialog object is instantiated? Some other
approach?
The above code looks like it works, but creates a new '<div class="ui-
dialog ui-draggable ui-resizable"...' each time, clearly wrong. I
thought I should maybe call destroy instead of close, but that leaves
the content completely blank next time; the original div#dlg still
exists in the dom, but it's hidden.
Re performance, in my particular test case, an ajax round trip
followed by a browser-native alert takes under a second. Using the
above dialog code instead, it takes 5-7 seconds for the alert to
appear. Both results are repeatable, on a fairly fast machine.
That's a huge difference, enough to completely negate the minimalism
of using ajax instead of a full server submission. Do other people see
anything like this? Is dialog so full featured that it's really this
degree of heavy? If so, it might be worth it for big-deal fancy edit
dlgs and such, but no way for simple alerts, pretty as they may be,
and consistent with other themed UI.
Or is it the code that's slowing this down? (Doubt it matters, but I'm
using a slightly modified version of one of the theme roller themes.)