How should I replace jQuery UI dialog?
jQuery hasn't been deprecated. Some unused jQuery UI components have been deprecated in 8.8 and will be removed in Drupal 9.0. core/jquery.ui.dialog is not among them.


[8.8 issue] Deprecate unused jQuery UI components in favour of a suite of contrib modules
[8.8 change record] Deprecated unused jQuery UI asset libraries
[9.0 issue] Remove deprecated jQuery UI components and fork remaining source code into core
[9.0 change record] jQuery UI source added to Drupal core and deprecated code removed


Nonetheless there's the new Dialog API. For that you have to require the core/drupal.dialog library or the core/drupal.dialog.ajax library for more advanced stuff. Some examples can be found in the docs on Ajax Dialog Boxes. The following sample requires the core/drupal.dialog.ajax library.


  This link opens /node/1 in a modal dialog box:

&lt;a class="use-ajax" 
    data-dialog-options="{&amp;quot;width&amp;quot;:400}" 
    data-dialog-type="modal" 
    href="/node/1"&gt;
    First node displayed in modal dialog.
&lt;/a&gt;



What you currently do in your code sample hasn't much to do with Drupal at all. To do it the Drupal way check the docs on adding JS/CSS to your module or theme first. You could attach the library simply to your theme or directly to all nodes of a given type for example.


Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 module
Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme