I need to add a JS script on the head tag, but only in the Success page. Inside Magento 2, I have no idea how doing this.
Someone can help me? :)
checkout_onepage_success.xml
file at following location on your custom extensionapp\code\Vendor\Extension\view\frontend\layout\checkout_onepage_success.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="Vendor_Extension::js/yourcustom.js"/>
</head>
</page>
yourcustom.js
on the following locationapp\code\Vendor\Extension\view\frontend\web\js\yourcustom.js
yourcustom.js
added your code what ever you want to add.You need to create checkout_onepage_success.xml layout in your module then adds the below code inside the page tag
<head>
<script src="Vendor_Module::js/custom.js"/>
</head>
After that, you can create custom.js file inside your custom module.