Google’s John Mueller suggests placing JavaScript code below the HTML header tag so that search crawlers can fully understand your website.
Mueller shared this advice in a Reddit thread. A user asks if the placement of the HTML code could cause her SEO problems.
The answer is yes. Not putting the HTML code at the top of the page can negatively impact your SEO efforts.
Specifically, in the HTML document
It’s important to place the section at the top of the page. This section should contain the information Google needs to read your site properly.JavaScript code should be placed below the HTML header.
JavaScript is
To make sure you’re not interfering with sections, Mueller recommends using Search Console’s rendering tools.“html header (
) should be almost at the top. Move the JS below the HTML header and in the Search Console rendering tool, the JS will appear as Make sure you didn’t mess up the section. “
As for the main content, according to Mueller, its placement isn’t that important, but it’s important for Googlebot to understand it properly.
It is important to keep the sections neatly organized.Mueller continues:
“While it’s less important with regards to content, the head part is for machine-readable information that has been identified to be in a specific part of the page, so it needs to be clean on top.
Down with JavaScript! (
inside)”
Why is JavaScript placement important for SEO?
When designing a website, the end of an HTML document is We recommend including the JavaScript code near the tag.
This is because JavaScript can delay rendering while a web page is loading, degrading the user experience.
Placing the JavaScript at the bottom of the page allows the user to view the content while the HTML is rendered first and the JavaScript loads in the background.
Additionally, you can use the async or defer attributes to prevent external JavaScript files from blocking page rendering.
sauce: Reddit
Featured Image: StockEU/Shutterstock
var s_trigger_pixel_load = false; function s_trigger_pixel(){ if( !s_trigger_pixel_load ){ striggerEvent( 'load2' ); console.log('s_trigger_pix'); } s_trigger_pixel_load = true; } window.addEventListener( 'cmpready', s_trigger_pixel, false);
window.addEventListener( 'load2', function() {
if( sopp != 'yes' && !ss_u ){
!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window,document,'script', 'https://connect.facebook.net/en_US/fbevents.js');
if( typeof sopp !== "undefined" && sopp === 'yes' ){ fbq('dataProcessingOptions', ['LDU'], 1, 1000); }else{ fbq('dataProcessingOptions', []); }
fbq('init', '1321385257908563');
fbq('track', 'PageView');
fbq('trackSingle', '1321385257908563', 'ViewContent', { content_name: 'googles-john-mueller-move-javascript-below-html-headers', content_category: 'news seo' }); } });