Description
The wsf_enqueue_script_strategy_defer filter hook can be used to override the Defer setting in Global Settings.
If set to true
, a defer
attribute will be added to all scripts enqueued by WS Form. The defer
attribute in HTML is used with <script>
tags to indicate that the script should be executed after the HTML document has been parsed, but before the DOMContentLoaded event.
Usage
add_filter( 'wsf_enqueue_script_strategy_defer', 'my_hook_function', 10, 1 );
Parameters
$strategy_defer
BooleanIf true, WS Form will add a defer attribute to all enqueued scripts.Default value:Per global setting
Example
// Callback function for the wsf_enqueue_script_strategy_defer filter hook function my_hook_function( $strategy_defer ) { // Your code here ... // Return value return $strategy_defer; } // Add a callback function for the wsf_enqueue_script_strategy_defer filter hook add_filter( 'wsf_enqueue_script_strategy_defer', 'my_hook_function', 10, 1 );
Source File
This hook can be found in:<plugin root>/includes/class-ws-form-common.php