1

I'm adding fontawesome script to my site, and I didn't found a proper way to add the fontawesome's integrity parameter (integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH").

There's a way to do this? Or wordpress doesn't have a current support

1 Answer 1

3

You will have to generate your own tag after the script is enqueued. Below, it's looking for the fontawesome handle (the one you're using to enqueue the script) before returning the custom tag.

add_filter( 'script_loader_tag', 'my_scripts_modifier', 10, 3 );
function my_scripts_modifier( $tag, $handle, $src ) {
    if ( 'fontawesome' === $handle ) {
        return '<script src="' . $src . '" type="text/javascript" integrity="sha384-DJ25uNYET2XCl5ZF++U8eNxPWqcKohUUBUpKGlNLMchM7q4Wjg2CUpjHLaL8yYPH"></script>' . "\n";
    }
    return $tag;
}
1
  • 1
    Thanks, I didn't know about this hook Commented May 29, 2019 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.