I wish to target an html element (<link> &lifier <script>) and wrap it by having an html comment string (<!-- -->).

out of this:

<link href="somecss" rel="stylesheet" />
<script src="somejs" type="text/javascript"></script>

for this

<!-- <link href="somecss" rel="stylesheet" /> -->
<!-- <script src="somejs" type="text/javascript"></script> -->

I understand this is often completed in the frontend with a couple javascript/jquery, However I wanted to get it done within the after sales while using function.php of wordpress. Any ideas how?

Thanks!

If you wish to prevent loading wordpress scripts you need to use wp_dequeue_script( $handle ) function. If will find description of $handle (default wordpress scripts) here.

If you wish to prevent loading wordpress styles you need to use wp_dequeue_style( $handle ) function.

You need to use this function after wordpress add default script and designs. You should use hook wordpress_enqueue_script rich in priority param (therefore it runs last): add_action('wp_enqueue_scripts', 'my_enquue_scripts', 100);

In case your primary theme have hardcoded scripts and designs in header.php - then you definitely cannot prevent loading from functions.php