Google’s John Mueller suggests inserting JavaScript code under the HTML header tag to make sure search crawlers can absolutely perceive your web site.
Mueller shares this recommendation in a Reddit thread, the place a consumer asks whether or not HTML code placement might trigger search engine optimisation points.
The reply is sure; the position of HTML code might adversely influence your search engine optimisation efforts if it doesn’t seem on the high of the web page.
Extra particularly, it’s necessary to maintain the <head> part of the HTML doc on the high of the web page. This part ought to comprise the knowledge that Google must learn your website correctly.
Any JavaScript code must be positioned under the HTML headers.
To guarantee that the JavaScript isn’t interfering with the <head> part, Mueller recommends utilizing the rendering device in Search Console:
“The html headers (<head>) must be just about on high. I’d transfer any JS to under the HTML headers, and examine with the rendering device in search console that the JS doesn’t mess up the <head> part.”
Relating to the principle content material, Mueller says its placement is much less necessary, although it’s essential for the <head> part to be clear and well-organized so Googlebot can correctly perceive it.
Mueller continues:
“For the content material it doesn’t matter as a lot, however for the reason that head stuff is for machine-readable data that’s verified to be in a particular a part of the web page, it actually must be clear on high.
Down with JavaScript! (within the <head>)”
Why Does The Placement Of JavaScript Matter For search engine optimisation?
When designing a web site, it’s greatest to incorporate JavaScript code on the backside of the HTML doc close to the closing </physique> tag.
That’s as a result of JavaScript can delay the rendering of a webpage whereas it hundreds, leading to a poor consumer expertise.
By inserting the JavaScript on the backside of the web page, the HTML could be rendered first, permitting the consumer to view the content material whereas the JavaScript hundreds within the background.
Moreover, you’ll be able to stop exterior JavaScript recordsdata from blocking the rendering of the web page utilizing the async or defer attributes.
Supply: Reddit
Featured Picture: 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' }); } });