Usage
This function runs automatically, so it is not called manually. Is this incorrect?
Source File
Located in /libs/Optimization.php on line 177.
2 Hooks
Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.
Filters
"nebula_defer_scripts""nebula_async_scripts"
Need a new filter hook? Request one here.
Actions
This function has no action hooks available. Request one?
PHP
public function defer_async_additional_scripts(){
if ( !$this->is_admin_page(true) ){
$to_defer = apply_filters('nebula_defer_scripts', array('jquery-migrate', 'jquery.form', 'contact-form-7', 'wp-embed')); //Allow other functions to hook in to add defer to existing scripts
$to_async = apply_filters('nebula_async_scripts', array()); //Allow other functions to hook in to add async to existing scripts
//Defer scripts
if ( !empty($to_defer) && is_array($to_defer) ){
foreach ( $to_defer as $handle ){
wp_script_add_data($handle, 'defer', true);
}
}
//Async scripts
if ( !empty($to_async) && is_array($to_async) ){
foreach ( $to_async as $handle ){
wp_script_add_data($handle, 'async', true);
}
}
}
}
Override
This function can not be short-circuited with an override filter. Request one?