17.1 Introduction

This is a HUGE chapter!!! But then, again, JavaScript is a HUGE subject! JavaScript is maintained by the European Computer Manufacturers Association (ECMA). JavaScript is often referred to as ECMA Script.

Where do I use Javascript? Here are just a few examples:

  • Interactive Webpages (Radio Buttons, Text Entry, dynamic changing of page attributes)
  • eLearning (SCORM, xAPI)
  • Data Visualization (D3JS)
  • You are using it to Knit this Markdown as well as provide all sorts of interaction!

Javascript is one of three primary standards that make up the World Wide Web Consortium (W3C). Other standards include:

  • HyperText Markup Language (HTML)
  • Cascading Style Sheets (CSS)
  • Standard Vectors Graphics (SVG)
  • jQuery (a derivative of JavaScript. Considered more lightweight)
  • Asynchronous JavaScript And XML (AJAX)

This may all appear confusing, but the reality is, most R developers who deploy {shiny} apps may not even leave RStudio. Therefore, one could claim the primary reason for adding additional JavaScript is to add hyper performance to your web app!

Note, at this point, I’m not calling it a {shiny} anymore, but a web app.

But what is going on under the hood?

  • {shiny} binds events to UI elements, and these JavaScript events will communicate with R
  • R talks to your browser through a web socket
    • Communication happens in both directions