官术网_书友最值得收藏!

The application's code structure

Let's review how the game's source code is structured. I like this project because the code is simple and demonstrates how much can be accomplished with a small amount of code in the browser.

There are three asset folders: js, meta, and style. They contain JavaScript files, images, and style sheets that are needed to render and execute the game.

You will also notice a node_modules folder. I added a local web server using grunt connect, which is a node module. The original game works just fine if you load the index.html file directly in the browser. However, due to security constraints, a service worker does not function without a web server. I will cover this in more detail shortly.

At the root-level, there are only handful of web application files:

  • index.html
  • manifest.json
  • sw.js
  • favicon.ico

The nice thing about the 2048 code is that it only requires a single HTML file. The manifest.json and sw.js files add the PWA functionality we are after. The favicon.ico file is the icon loaded by the browser for the address bar:

主站蜘蛛池模板: 满洲里市| 井冈山市| 孝昌县| 启东市| 澄城县| 彭山县| 韩城市| 云龙县| 甘孜| 出国| 武夷山市| 娱乐| 白银市| 榆社县| 肃宁县| 新河县| 平乡县| 彭州市| 舒城县| 磐石市| 东港市| 云林县| 兰考县| 东乡县| 西城区| 京山县| 大港区| 儋州市| 车致| 万安县| 湄潭县| 延庆县| 舟山市| 纳雍县| 吴忠市| 永春县| 桑日县| 普兰县| 宁波市| 蕉岭县| 米易县|