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

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:

主站蜘蛛池模板: 三都| 石棉县| 天等县| 扎鲁特旗| 南开区| 贡山| 南溪县| 上栗县| 连江县| 从江县| 阜阳市| 象州县| 淮南市| 金堂县| 城固县| 西丰县| 安化县| 镇坪县| 阜阳市| 义乌市| 惠来县| 边坝县| 澳门| 东阿县| 阜阳市| 蓬莱市| 茂名市| 桂阳县| 安仁县| 青阳县| 兰溪市| 上虞市| 大连市| 南投县| 麻栗坡县| 密山市| 凌海市| 涟水县| 苏尼特右旗| 穆棱市| 牡丹江市|