Success template is shared with few different submit processes. It will not be right to add it to that template.
You can add javascript to success controller. It will be loaded right after order is placed.
/storefront/controller/pages/checkout/success.php
Add:
$this->document->addScript(RDIR_TEMPLATE . 'javascript/[YOUR FILE]');
somewhere after line:
$this->extensions->hk_InitData($this,__FUNCTION__);