Question
Which method of placing the
<script>
tags is "best-practice?"
- Inside the
<dom-module>
?or
- Outside the
<dom-module>
?
Also, please answer:
- Why?
- What is the source of your answer?
- What downside risks are there by doing it the "wrong" way?
Polymer Starter Kit: OUTSIDE
In the Polymer Starter Kit, the my-list.html
and my-greeting.html
files place the <script>
tag outside the <dom-module>
.
Like this:
<dom-module>
<style>...</style>
<template>...</template>
<dom-module>
<script>...</script>
Other Experts: INSIDE
However, I have heard and seen several examples from Google employees and Google developers that suggest the <script>
tags should go inside the <dom-module>
.
Like this:
<dom-module>
<style>...</style>
<template>...</template>
<script>...</script>
<dom-module>