Community Forums › Forums › Archived Forums › General Discussion › Modernizer in Head ruins HTML output
Tagged: javascript, modernizr
- This topic has 5 replies, 2 voices, and was last updated 10 years, 6 months ago by devongroup.
-
AuthorPosts
-
October 10, 2013 at 4:15 pm #66186devongroupMember
Hello I am having an issue where when you use modernizr.js script the which worked in Genesis 1.9.2 is now pushing everything outside of the:
<main class="content" role="main" itemtype="http://schema.org/Blog" itemscope="itemscope" itemprop="mainContentOfPage"/>
Now you can place it in the footer but is causes a massive Flicker and my mobile toggle nav displays for a second covering the page. In the header it is seemless and this does not happen.
This main content is where people use styles to control the width. I now have a 100% width for this container which means my sidebars are dropping below this. Has this issue been reported? Both modernizr.js and modernizr-2.6.2-respond-1.1.0.min.js face the same issue. Just went back to a test version of 1.9.2 and all is well but when activating the Genesis 2.0.1 and HTML it dumps everything outside of:
<main class="content" role="main" itemtype="http://schema.org/Blog" itemscope="itemscope" itemprop="mainContentOfPage"/>
PLEASE let's fix this issue as modernizr is needed and should be placed in the head to avoid the massive Flicker. It works fine in Genesis 1.9 but 2.0 it's not so good.
Genesis 2.0 is assume all but for this issue.
October 11, 2013 at 1:44 pm #66325ramseypMemberHi there,
How are you loading Modernizer? I've got it loading in the head on a Genesis 2.0 site ( everything up to date, Genesis, plugins, etc. ).
How I load it ( along with other scripts and css ):
`add_action( 'genesis_meta','s25_load_scripts' );
function s25_load_styles() {
if ( !is_admin() ) {
$js_loc = CHILD_URL.'/lib/js/';
wp_register_script( 'modernizr', $js_loc.'modernizr.custom.70177.js', array( 'jquery' ), '6.1',false );
wp_register_script( 'custom', $js_loc.'custom.js', array( 'jquery' ), '1.0',false );
wp_enqueue_script( 'modernizr' );
wp_enqueue_script( 'custom' );
}
}
October 11, 2013 at 2:28 pm #66334devongroupMemberSorry I think your single quotes copied incorrectly as it just errors when I try your code. Below is how I am working with it. I have been informed that modernizer running in the head is having issues with the Genesis framework and support is not given as it is a 3rd party script.
Are you not having the same issue as I am if you place modernizr.js in the head?
if (! is_admin() ) {
wp_register_script( 'modernizr', CHILD_URL.'/lib/js/modernizr-2.6.2-respond-1.1.0.min.js', array(), '1.1.0', false );
wp_enqueue_script( 'modernizr' );
}October 11, 2013 at 2:58 pm #66339devongroupMemberUsing a not so satisfying method I did get the script into the head and to interact with IE8 correctly, would you be able to give me some tips on how to best enqueue scripts in wordpress so I can place scripts in both the header (close to the bottom if not the bottom) and also into the footer. Here was the kind of hack but it is good to know it atleast works, and heck IE8 better be on it's way out anyways. I sent Nick from studiopress and email about this to see if the team working on Genesis could resolve the issue.
add_action('wp_head', 'company_head_content');
function company_head_content() { ?>
<script src="/wp-content/themes/company/lib/js/modernizr-2.6.2-respond-1.1.0.min.js"></script>
<?php }October 11, 2013 at 7:52 pm #66358ramseypMemberHi there -
The way you've included the script will get it placed in the head, but by not enqueuing it could cause problems down the road.
This is a great article on properly loading scripts: http://wpcandy.com/teaches/how-to-load-scripts-in-wordpress-themes/
Try this & see if it works:
add_action( 'wp_enqueue_scripts', 's25_load_scripts' ); function s25_load_styles() { if ( !is_admin() ) { $js_loc = CHILD_URL.'/lib/js/'; wp_register_script( 'modernizr', $js_loc.'modernizr.custom.70177.js', array( 'jquery' ), '6.1′, false ); wp_register_script( 'custom', $js_loc.'custom.js’, array( 'jquery' ), '1.0', false ); wp_enqueue_script( 'modernizr' ); wp_enqueue_script( 'custom' ); } }
October 22, 2013 at 8:41 am #68193devongroupMemberThanks for this, had to complete a different assignment, I hope to rewrite the way my scripts are loaded following your advice, I will get back to you with the results. I do have a question, this is the first time seeing
$js_loc = CHILD_URL.'/lib/js/';
Can you explain or lead me to an article which does, thanks so much.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.