javascript - Populating Meta Tags before DOM is loaded -


so weird 1 - 1 have resolve.

i populating meta tags based on whether form present or not. used form id in .ready() function because jquery comes before (in head) in dom.

this analytics script , script's event in footer. script firing before tags populated , no data being sent. unfortunately, cannot modify script.

is possible pause dom loading on .ready() event of form?

var wturl = window.location.pathname; var wturlparse = wturl.split('/'); var apptype = '1';  if (wturlparse[3] == 'app') {     var apptype = '2'; } else {     var apptype = '1' }   document.write('<meta name="placeholder">');   $('#createusername').ready(function(e) {     e.preventdefault;     var isform = $('#createusername').length; console.log(isform);      if ( $('#createusername').length == 1 ) {         $('meta[name="placeholder"]').after('<meta name="junk" content="'+ apptype +' stuff">\n<meta name="junk2" content="stuff2">');         $('meta[name="placeholder"]').remove();     }     else {         if ( $('#createusername').length == 0 ) {             $('meta[name="placeholder"]').after('<meta name="junk" content="'+ apptype +' stuff">\n<meta name="junk2" content="stuff2">\n<meta name="junk3" content="stuff3">');             $('meta[name="placeholder"]').remove();         }     } }); 

this seems bad idea.

<meta> tags intended go in head of document. javascript have synchronously executed in head of document in order document.write tags in place correctly. synchronous execution blocks rendering of page , terrible performance.

meta tags - google webmaster tools help


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -