My theme looks good and it works so far, but in the first seconds of loading the whole layout looks buggy: http://andreapuiatti.de/screenshots/cssstylebug.png
I think is because the css has been loaded with a delay but even positioning the wp_enqueue_style on the top of my functions.php doesn't make any difference
Any Idea on how to fix that?
Follows part of the functions.php
// Load Stylesheets
function addMyStyles() {
wp_register_style('reset', get_template_directory_uri().'/reset.css');
wp_register_style('style', get_template_directory_uri().'/style.css', array('reset') );
wp_enqueue_style('style');
}
add_action('wp_head', 'addMyStyles');
// Load Scripts
if ( !function_exists( 'core_mods' ) ) {
function core_mods() {
if ( !is_admin() ) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ), false);
wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'core_mods' );
}
function addMyScripts() {
/*wp_register_script( 'modernizr', get_template_directory_uri().'/_/js/modernizr.js', null, false );
wp_enqueue_script( 'modernizr' );*/
wp_register_script( 'jwplayer', get_template_directory_uri().'/_/js/jwplayer.js', null, false );
wp_enqueue_script( 'jwplayer' );
wp_register_script( 'bootstrap', get_template_directory_uri().'/_/js/bootstrap.js', array('jquery'), false );
wp_enqueue_script( 'bootstrap' );
wp_register_script( 'spk_slide', get_template_directory_uri().'/_/js/slides.js', array('jquery'), false );
wp_enqueue_script( 'spk_slide' );
}
//add_action('wp_enqueue_scripts', 'addMyScripts');
// Add slider to front page
function my_enqueue_stuff() {
if ( is_front_page() ) {
addMyScripts();
}
}
add_action( 'wp_enqueue_scripts', 'my_enqueue_stuff' );
SOLVED: after research I found out that that effect name is FOUC (flash of unstyled content). I just had to increase the priority of the function which is adding the stylesheets to get them added to the head section: add_action( 'wp_enqueue_scripts', 'core_mods','2' ).
<head>
of your site so the content displays, then the CSS is loaded, then the browsers suddenly styles your page.core_mods
function just hijacks the Core JQuery. I don't see how that alters where the stylesheet loads. Something is still missing.