Wordpress script with integrity and crossorigin

前端 未结 7 1274
旧时难觅i
旧时难觅i 2021-02-03 12:07

I\'m trying to use the wp_register_script and wp_enqueue_script FUNCTION on WordPress to enqueue a script, which has two attributes: \"integrity\" and \"crossorigin\".

N

7条回答
  •  既然无缘
    2021-02-03 12:20

    By jQuery,

    jQuery( function( $ ) {
        $( document ).ready(function() {
            var strapatt = document.getElementById('bootstrap-css');
            strapatt.setAttribute("integrity", "sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb");
            strapatt.setAttribute("crossorigin", "anonymous");
        });
    });
    

提交回复
热议问题