It is completely useless to add doctype using JavaScript, since doctype will be resolved before JavaScript can add it to the page. Editing or adding a doctype type using JavaScript will not cause the page to display using processed JavaScript doctype.
source
share