'/assets/css/main.css', 'js' => '/assets/js/scripts.js', 'modernizr' => '/assets/vendor/modernizr/modernizr.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js' ); } else { $get_assets = file_get_contents(get_template_directory() . '/assets/manifest.json'); $assets = json_decode($get_assets, true); $assets = array( 'css' => '/assets/css/main.min.css' . '?' . $assets['assets/css/main.min.css']['hash'], 'js' => '/assets/js/scripts.min.js' . '?' . $assets['assets/js/scripts.min.js']['hash'], 'modernizr' => '/assets/js/vendor/modernizr.min.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' ); } wp_enqueue_style('roots_css', get_template_directory_uri() . $assets['css'], false, null); /** * jQuery is loaded using the same method from HTML5 Boilerplate: * Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline * It's kept in the header instead of footer to avoid conflicts with plugins. */ if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); wp_register_script('jquery', $assets['jquery'], array(), null, false); add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); } if (is_single() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } wp_enqueue_script('modernizr', get_template_directory_uri() . $assets['modernizr'], array(), null, false); wp_enqueue_script('jquery'); wp_enqueue_script('roots_js', get_template_directory_uri() . $assets['js'], array(), null, true); } add_action('wp_enqueue_scripts', 'roots_scripts', 100); // http://wordpress.stackexchange.com/a/12450 function roots_jquery_local_fallback($src, $handle = null) { static $add_jquery_fallback = false; if ($add_jquery_fallback) { echo '' . "\n"; $add_jquery_fallback = false; } if ($handle === 'jquery') { $add_jquery_fallback = true; } return $src; } add_action('wp_head', 'roots_jquery_local_fallback'); /** * Google Analytics snippet from HTML5 Boilerplate */ function roots_google_analytics() { ?>