Display webform in a modal
Displaying a weform in modal (might be called popup as well) it is a lot simpler than you thought
Lets assume your webform has URL /contact than you can create a link in the following manner
&lt;a class=&quot;use-ajax&quot; data-dialog-type=&quot;modal&quot; href=&quot;/contact&gt;Contact US&lt;/a&gt;

Pressing that link will have your form open in a modal with error validation and messages inside the modal
NOTE:
At least in my case I had to also add the following hook_preprocess_page in the .theme file
function THEMENAME_preprocess_page(&amp;$vars) {
    //custom logic of when to include the library
    // ....
    $vars['#attached']['library'][] =  'core/drupal.dialog.ajax';  
}

Some people have reported that this is not needed but I assume some other module included this library for them ...