Public Ticket #1867082
Preload key requests compatibility


  •  1
    sb124489 started the conversation

    Hello. After some tests, I want to add <link rel=preload> in my header. Is this compatible with Moody theme? 

  •  131
    Steve replied


    Thanks for writing us.

    By default there is no option and it requires cutomization. However you can try add following code in functions.php file and check if that helps?

    add_action('wp_head', function () {
        global $wp_scripts;
        foreach($wp_scripts->queue as $handle) {
            $script = $wp_scripts->registered[$handle];
            //-- Weird way to check if script is being enqueued in the footer.
            if($script->extra['group'] === 1) {
                //-- If version is set, append to end of source.
                $source = $script->src . ($script->ver ? "?ver={$script->ver}" : "");
                //-- Spit out the tag.
                echo "<link rel="preload" href="{$source}" as="script">\n";
    }, 1);

    Best Regards,
    Steve Piper

    Thememove Support

  •  1
    sb124489 replied

    Thank you!