Add FICTIONEER_DEFER_SCRIPTS constant

This commit is contained in:
Tetrakern 2024-03-07 00:19:40 +01:00
parent 5ab0d21f4e
commit 792e91cac5
3 changed files with 8 additions and 1 deletions

View File

@ -1368,4 +1368,5 @@ define( 'CONSTANT_NAME', value );
| FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER | boolean | Whether to order updated stories based on the latest chapter added, excluding stories without chapters. Default `false`.
| FICTIONEER_ENABLE_STORY_CHANGELOG | boolean | Whether changes to the story chapter list should be logged. Default `true`.
| FICTIONEER_ENABLE_BROWSER_NOTES | boolean | Whether to inform visitors of missing browser features. Default `true`.
| FICTIONEER_DEFER_SCRIPTS | boolean | Whether to defer scripts or load them in the footer. Default `true`.
| FICTIONEER_EXAMPLE_CHAPTER_ICONS | array | Collection of example Font Awesome icon class strings.

View File

@ -381,6 +381,11 @@ if ( ! defined( 'FICTIONEER_ENABLE_BROWSER_NOTES' ) ) {
define( 'FICTIONEER_ENABLE_BROWSER_NOTES', true );
}
// Boolean: Defer scripts
if ( ! defined( 'FICTIONEER_DEFER_SCRIPTS' ) ) {
define( 'FICTIONEER_DEFER_SCRIPTS', true );
}
/*
* Arrays
*/

View File

@ -793,7 +793,8 @@ if ( ! function_exists( 'fictioneer_add_font_awesome' ) ) {
function fictioneer_add_custom_scripts() {
// Setup
$post_type = get_post_type();
$strategy = fictioneer_compare_wp_version( '6.3' ) ? array( 'strategy' => 'defer' ) : true; // Defer or load in footer
$strategy = fictioneer_compare_wp_version( '6.3' ) && FICTIONEER_DEFER_SCRIPTS
? array( 'strategy' => 'defer' ) : true; // Defer or load in footer
// Utility
wp_register_script( 'fictioneer-utility-scripts', get_template_directory_uri() . '/js/utility.min.js', [], FICTIONEER_VERSION, $strategy );