Safe to add a class attribute to the HTML element via the theme?
You should use .addclass():

&lt;html{{ html_attributes.addClass('no-js') }}&gt;


That would prevent the output in the example from your question and the result will be:

&lt;html class="drupals-class no-js"&gt;