Go on the Front-End with GopherJS

Ever since its creation, JavaScript has been the de facto programming language of the web browser. Accordingly, it has had a monopoly over front-end web development for a very long period of time. It's been the only game in town that comes with the capability to manipulate a web page's Document Object Model (DOM) and access various application programming interfaces (APIs) implemented in modern web browsers.

Due to this exclusivity, JavaScript has been the only viable option for isomorphic web application development. With the introduction of GopherJS, we now have the ability to create Go programs in the web browser, which also makes it possible to develop isomorphic web applications using Go. 

GopherJS allows us to write programs, in Go, that get converted into an equivalent JavaScript representation, which is suitable to run in any JavaScript-enabled web browser. GopherJS provides us with a viable and attractive alternative to using JavaScript, especially if we are using Go on the server side. With Go on both ends of the spectrum (front-end and back-end), we have new opportunities to share code and eliminate the mental context shifts that come with having to juggle different programming languages across environments.

In this chapter, we will cover the following topics:

  • The Document Object Model
  • Basic DOM operations
  • GopherJS overview
  • GopherJS examples
  • Inline template rendering
  • Local storage
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.3.175