Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables JIT mode #726

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
308 changes: 162 additions & 146 deletions composer.lock

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions inc/extras.php
Expand Up @@ -99,3 +99,25 @@ function _s_copyright_year( $atts ) {
}

add_shortcode( '_s_copyright_year', '_s_copyright_year', 15 );

/**
* Retrieve the URL of the custom logo uploaded, if one exists.
*
* @author Corey Collins
*/
function _s_get_custom_logo_url() {

$custom_logo_id = get_theme_mod( 'custom_logo' );

if ( ! $custom_logo_id ) {
return;
}

$custom_logo_image = wp_get_attachment_image_src( $custom_logo_id, 'full' );

if ( ! isset( $custom_logo_image[0] ) ) {
return;
}

return $custom_logo_image[0];
}
39 changes: 38 additions & 1 deletion inc/scripts.php
Expand Up @@ -30,5 +30,42 @@ function _s_scripts() {
wp_enqueue_script( 'comment-reply' );
}
}

add_action( 'wp_enqueue_scripts', '_s_scripts' );

/**
* Preload styles and scripts.
*
* @author WebDevStudios
*/
function _s_preload_scripts() {
$asset_file_path = dirname( __DIR__ ) . '/build/index.asset.php';

if ( is_readable( $asset_file_path ) ) {
$asset_file = include $asset_file_path;
} else {
$asset_file = [
'version' => '1.0.0',
'dependencies' => [ 'wp-polyfill' ],
];
}

?>
<link rel="preload" href="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/build/index.css?ver=<?php echo esc_html( $asset_file['version'] ); ?>" as="style">
<link rel="preload" href="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/build/index.js?ver=<?php echo esc_html( $asset_file['version'] ); ?>" as="script">
<?php
}
add_action( 'wp_head', '_s_preload_scripts', 1 );

/**
* Preload assets.
*
* @author Corey Collins
*/
function _s_preload_assets() {
?>
<?php if ( _s_get_custom_logo_url() ) : ?>
<link rel="preload" href="<?php echo esc_url( _s_get_custom_logo_url() ); ?>" as="image">
<?php endif; ?>
<?php
}
add_action( 'wp_head', '_s_preload_assets', 1 );