Level 0
Level 1

Scripts

A script is a small bit of code that enables web browsers to do something more than just displaying static results. Scripts are used in web design to create dynamic pages. So far you have included noscript inside your polymer element. The reason is because untill now we did not use the script functionalities. There are some big differences between regular HTML scripts and Polymer scripts. Scripts are extremely powerful and are responsible for the behaviour of your web-app.

Create a script

Where HTML specifies the strucutre, and CSS the styling, scripts allow for behaviour. To add behaviour you create a script tag and inside most commonly JavaScript is used. JavaScript works by finding a target HTML element, and then doing something to it, just like CSS, but the syntax is different.

Instructions
Resources

Set up a Script in Polymer

Now you know how to use scripts in regular HTML but how do you do that in Polymer? When you do not include a script, you need to explicitly tell Polymer that by adding the noscript attribute. When you do, you leave that attribute out. In Polymer the syntax to include a script is different from that in regular HTML. Till now all the Polymer elements included this noscript. This time we add the basic syntax to include a script inside a Polymer component.

Instructions
Resources

Create Scripts with Polymer

In this case we will use the script to set our values, and we will use the double bracket method (like handlebars) to insert those values elsewhere. In Polymer we do not have to target specific elements. The element containing the script already indicates where we want our script to run. This is an example where we do not just alter the styling anymore but use a script to store information. This is useful in combination with the repeat attribute of Polymer's template tag.

Instructions
Resources