Support » Plugin: Scripts To Footer » Facebook Pixel to header

  • Resolved wandriska

    (@wandriska)


    I need to put a FB Pixel in Header, however this plugin won’t let me use other plugin that does that.
    I am scared to delete this plugin as not sure what script I will delete when I do that.
    ANy suggestions would be welcomed.
    thank you
    Andrew

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Andrew,

    There is a method to keep a specific scripts in the header whole Scripts To Footer is active. Check out the main plugin page and/or the FAQ tab. I’m responding to this on my phone, but I’ll be at my computer tomorrow and I’ll followup with a link and code snippet.

    Deleting or deactivating STF will not remove any scripts, but everything will end up in the header.

    Hope that helps!
    Joshua

    That sounds promising Joshua.

    Is there a way of seeing what scripts STF have moved to the footer?

    many thanks!
    Andrew

    Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Andrew,

    All scripts properly registered through the wp_enqueue_scripts hook will be moved to the footer. If your theme or plugin are using another method to insert scripts, the plugin will not have any effect on them. You can view your html output with the plugin on and off to take a closer look at which scripts are being inserted in the header/footer.

    You can also disable the plugin on specific pages (see the Documentation).

    The plugin will manually insert specific scripts into the header if you utilize the stf_exclude_scripts filter in your functions.php file. You’ll need to first determine the slug that the script is registered with (this may require digging through the plugin files, reaching out to their developer, see the WP Codex documentation on the wp_enqueue_script function).

    Once you have the slug, you can insert it in place of the ‘backbone’ slug used in the example below:

    add_filter( 'stf_exclude_scripts', 'jdn_header_scripts', 10, 1 );
    function jdn_header_scripts( $scripts ) {
        $scripts[] = 'backbone'; // Replace 'backbone' with the script slug
        return $scripts;
    }

    Thanks for that! 🙂

    Plugin Author Joshua David Nelson

    (@joshuadnelson)

    Andrew,

    I’m going to close this thread, sounds like it worked. If you have any other questions/issues, let me know!

    Cheers,
    Joshua

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Facebook Pixel to header’ is closed to new replies.