Should I define my web components <template></template>
in the head or the body of my html document? I know I can define it in either, but is there a best practice or any reason at all that I might want to place it in one over the other?
Remember that the content of <template>
is not rendered. Technically it isn't even parsed.
If you are creating all of your web components within your page then placement of your <template>
tag doesn't really matter, except that placing it after all of your content, in theory, will allow the page to render faster.
If you are using individual HTML files for each web component then place the <template>
in each of those.
If you are using JS files for each web component then embed the template as a string or use something like gulp-component-assembler to bring you templates into the JS file.