Scripts are loaded using the WP function wp_enqueue_script(), in the themes/cornell/lib/setup.php file.

If you need to add an attribute to a script tag, such as the "async" attribute, you'll need to add the following function and hook in the theme's functions.php file. (On the Giving site, this will be in the themes/cornell-giving folder.) Substitute the cornell/plugin-handle for the one you need to amend:

 

function cornell_amend_script($tag, $handle, $src) {
  if ($handle === 'cornell/plugin-handle') {
   if (false === stripos($tag, 'async')) {
   $tag = str_replace(' src', ' async="async" src', $tag);
  }
 }
 return $tag;
}
add_filter('script_loader_tag', 'cornell_amend_script', 10, 3);

  • No labels