Add code to  for specific content type
The quick way

and maybe some will call it dirty way would be to add in your THEMENAME.theme file

function THEMENAME_preprocess_html(&amp;$vars) {  
  $node = \Drupal::routeMatch()-&gt;getParameter('node');
  if ($node instanceof \Drupal\node\NodeInterface) {
    // You can get nid and anything else you need from the node object.
    $vars["content_type"] = $node-&gt;bundle();
  }
}


and then in your html.html.twig

{% if content_type == "page" %}
  &lt;script&gt; ... &lt;/script&gt;
{% endif %}      


alternatively

you can just put it in a .js file and include like this 

function my_module_preprocess_html(&amp;$variables) {
  // To get around the issue of D8 core escaping inline js we cram our js
  // file into a twig variable for printing "raw" in "html.html.twig" like so: 
  // {{ my_module_script|raw }}
  $variables['my_module_script'] = '&lt;script type="text/javascript"&gt;' . file_get_contents(dirname(__FILE__) . '/js/script.js') . '&lt;/script&gt;';
}


as described in this comment

proper way is probably to

Define a library and then to attach it following this guide