magento2 – Magento custom PHTML correct way to snip in the code

Hi all I have a script need to snip in to the custom.phtml
How do I snip it in correctly?

such as I have to remove html and body tags. How about the include jquery thing?

<script src=""></script>

I need to remove it as well right or have some other replacement?

        <script src=""></script>
        <script id="mediaTemplate" type="text/x-jsrender">
    <div class="candid-wall-cell">
        <div class="candid-wall-overlay">
        <div class="candid-wall-overlay-text">
            <i class="candid-icon candid-fa-{{> Media.Source.toLowerCase() }}"></i>
            <div>SHOP NOW</div>
        <a class='media' data-media-index='{{> Index }}'>
            <img data-original="{{> Media.Images.LowResolution.Url }}" 
                 alt="{{> Title }}" 
        <script type="text/javascript" 
        <script type="text/javascript">
            candid.wall('#container', { 
                cluster: 'prod-2',
                layoutMode: 'masonry',
                layout: 'standard',
        <div id="container"></div>