WordPress: Add inline JS in theme functions or code snippet fast and simply

Date: 
12. January 2024
Author: 
mbs
Category: 

This is pretty simply, and a needed thing for me sometimes. Despite I run from a lifeset of not including JS on a website, if I can skip it 🙂 I love performance

But this can't be done on advanced webpages sometimes, so here is a quick code so you can add script fast in theme functions without the need of a plugin

add_action('wp_head','woocommerce_js');

    function woocommerce_js()
    { // break out of php ?>

  <script>


SCRIPT GOES IN HERE
    </script>


    <?php } // break back into php

Leave a Reply

Your email address will not be published. Required fields are marked *

© Copyright 2007-2024
mbsTECH.dk

Build with
and 
Oxygenbuilder
I'm using 
Ahoy