JavaScript - Amazon Silk

JavaScript

Amazon Silk uses the V8 JavaScript engine to compile and execute JavaScript.

Using the Amazon Silk Settings menu, users can enable or disable JavaScript. The setting is enabled by default.

To learn more about the Settings menu, see Accessing the Settings Menu.

When JavaScript is disabled, Silk ignores the content of <script> tags. You can use the <noscript> tag to let users know that JavaScript content is disabled.

<html> <body> <h1>Test Script</h1> <script>document.write("JavaScript is enabled in your browser.")</script> <noscript>It looks like JavaScript is disabled in your browser, or your browser doesn't support JavaScript.</noscript> </body> </html>

Here's the output of the above markup rendered by Amazon Silk with JavaScript disabled:

JavaScript Loading

Though not specific to Amazon Silk, the following recommendations for loading JavaScript can improve the performance of your website.

  • Wherever practical, combine multiple external script files into a single file to improve page load time.

  • Avoid including duplicate scripts on a page.

  • Include external CSS files before external scripts. Otherwise script loading may block style sheet loading. And include script files as far down the page as possible. HTML parsing is blocked by the downloading and execution of scripts.

  • Don't put inline scripts between included CSS files and other resources. Like an external script, an inline script can prevent a CSS file from downloading in parallel to other resources. In general, it's best to avoid inline scripts altogether and instead include external JavaScript files.

  • Use minified JavaScript. Minified JavaScript files are smaller and therefore download faster. Available tools for compressing JavaScript include UglifyJS, Closure Compiler, and YUI Compressor.

  • Consider using the async and defer attributes in your script elements. With async set, a script is downloaded asynchronously and then executed, blocking HTML parsing. With defer set, a script is downloaded asynchronously and then executed after HTML parsing has completed.

To learn more about improving load times for scripts, see the following resources: