Making “Bite-Sized” Web Games with GameSnacks

Rate this content
Bookmark

One of the great strengths of gaming on the web is how easily accessible it can be. However, this key advantage is often negated large assets and long load times, especially on slow mobile connections. In this talk, Alex Hawker from Google’s GameSnacks will illustrate how they are tackling this problem and some key learnings the team found while optimizing third party games and designing their own ultra-lightweight game engine.

Alex Hawker
Alex Hawker
33 min
07 Apr, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Welcome to making bite-sized games with GameSnacks, a platform that focuses on optimizing game sizes for easy accessibility on the web. Techniques such as lazy loading, script placement, and code and art optimization can greatly improve game performance. Choosing the right file formats, reducing game size, and using game engines or custom tools are important considerations. Prioritizing file size, testing internet connections, and using testing tools for accurate simulation can help attract more users and improve game retention and reach.

1. Introduction to GameSnacks and Game Optimization

Short description:

Welcome to making bite-sized games with GameSnacks. The web has the advantage of easy accessibility for gaming, but large file sizes hinder this. Gamesnacks is working on optimizing game sizes. Using gzip encoding and showing visual elements quickly improve user experience.

Hello, and welcome, everyone, to making bite-sized games with GameSnacks. I'm Alex Hawker, I'm a software engineer on the GameSnacks team at Google. My main focus has been a variety of web gaming infrastructure and distribution-related projects, many of which revolve around this very challenge of optimizing web game file size.

Now, you may be thinking, why bite-sized games? Aren't internet speeds good enough these days? Well, one of the key advantages of the web as a platform for gaming is its capability for virality, perfectly expressed in examples from io Games to the recent hit, Wordle. But this advantage of easy accessibility is severely negated when file sizes soar too high. Despite advances like 5G, much of the world still frequently experiences slower connections, from Australia, to India, to right here in the US. I know I've certainly experienced many times in places where my phone's internet speed suddenly slows to a crawl. And in times like these, when even just a 10 megabyte game can take over 3 minutes to download, every byte counts. No one wants to see that blank screen on the left, they want to play some games.

Well this is one of the things that we're working on here at Gamesnacks. Gamesnacks is a new team at Google dedicated to growing the web gaming ecosystem to help make games universally accessible and useful. As part of this effort, we've experimented heavily with optimizing games and their file sizes. Even going so far as to build an experimental game engine to see just how far you can take these optimizations, and how worthwhile the various types can be. I'm here today to share with you the highlights of these learnings. We'll start with a few general considerations that apply to optimizing game size then dive into specific optimizations for different file types.

First off, using gzip encoding on game files is an easy first step to improving file savings. On average, it reduces the file size of code and other applicable files by 75%. For those unfamiliar, gzip is essentially an open source equivalent to zip. Browsers today support servers sending them these gzip-compressed files, which allows us to reduce how many bytes we need to send. However, due to the way gzip works, it doesn't work well on every file. You should instead only use it on uncompressed files like code, configs, and specific formats like svg or midi. Unlike other tips, using gzip is not a change made to the game project itself, but instead has to be enabled on the server. Fortunately, this is usually pretty straightforward. For instance, in Google Cloud Storage, you can just add this Zed flag with the list of extensions you want gzipped.

Next up, we've got well this is kind of an awkward pause. Not really all that pleasant, which is why it's so important to get some sort of visual shown to users quickly. This is critical, because research shows that just having the page load time go from 1 second to 5 seconds increases the bounce rate of the page by 90%. So showing the user some ideally animated visual — whether a splash screen or a loading screen — reassures them that things aren't broken, and gives them something to focus on to make the load feel faster to the user. So even though this won't improve the total load times, or likely might even make it slightly worse, it's overall a very big win, since at the end of the day, the user's perception is what matters, not the raw metrics. In a similar vein, lazy loading content can be a big win.

2. Lazy Loading and JavaScript Size

Short description:

Lazy loading is a technique where you only load the content that you need at the current point in time. This can be done on a fine-grained level, loading assets on the fly and using placeholders. It helps get the user into the game faster and reduces the average download required. JavaScript is relatively small compared to Visuals and Audio in terms of file size, but it can be heavier than it seems.

This is when, rather than loading everything eagerly ahead of time, you only load the content that you need at the current point in time. So if we had this space game with four worlds, maybe we'd only load the core game mechanics and the rocket ship level assets first, and defer the rest to be loaded later when the player gets to it. You can also do this on a more fine-grained level, where individual assets are loaded on the fly and rendered with placeholders in the meantime.

This is a popular technique in Unreal Engine with rendering low-resolution versions of textures as a placeholder to speed up loading times. With these techniques, even though the total game size stored on a server doesn't decrease, it really helps get the user into the game a lot faster and often reduces the average download required. There are some trade-offs though, as this does require careful planning and code to handle breaking up the game into self-contained segments, which is easier for some game types and some game engines than it is on others. Additionally, if you're planning on embedding this game on the user's device, for instance with something like Cordova or Electron, lazy loading isn't going to give you many big wins since the user needs the entire thing anyways.

Now that we've covered some general tips, let's take a deeper dive into some key contributors of file size. I've broken down a typical web game from our catalog down into what composes its GZIPed file size, and we can clearly see three major categories emerge — JavaScript, Visuals, and Audio. Let's start with JavaScript. So JavaScript is relatively small compared to Visuals and Audio. Our representative game, thanks in part to GZIP, had JavaScript composing only 20% of its overall size, compared to 43% of Visuals and Audio. However, even though its raw file size is smaller, JavaScript can be a lot heavier than it at first seems.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Optimizing HTML5 Games: 10 Years of Learnings
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Optimizing HTML5 Games: 10 Years of Learnings
Top Content
The open source PlayCanvas game engine is built specifically for the browser, incorporating 10 years of learnings about optimization. In this talk, you will discover the secret sauce that enables PlayCanvas to generate games with lightning fast load times and rock solid frame rates.
Building Fun Experiments with WebXR & Babylon.js
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Building Fun Experiments with WebXR & Babylon.js
Top Content
During this session, we’ll see a couple of demos of what you can do using WebXR, with Babylon.js. From VR audio experiments, to casual gaming in VR on an arcade machine up to more serious usage to create new ways of collaboration using either AR or VR, you should have a pretty good understanding of what you can do today.
Check the article as well to see the full content including code samples: article. 
Making Awesome Games with LittleJS
JS GameDev Summit 2022JS GameDev Summit 2022
34 min
Making Awesome Games with LittleJS
LittleJS is a super lightweight game engine that is easy to use and powerfully fast. The developer will talk about why he made it, what it does, and how you can use it to create your own games. The talk will include a demonstration of how to build a small game from scratch with LittleJS.
How Not to Build a Video Game
React Summit 2023React Summit 2023
32 min
How Not to Build a Video Game
In this talk we'll delve into the art of creating something meaningful and fulfilling. Through the lens of my own journey of rediscovering my passion for coding and building a video game from the ground up with JavaScript and React, we will explore the trade-offs between easy solutions and fast performance. You will gain valuable insights into rapid prototyping, test infrastructure, and a range of CSS tricks that can be applied to both game development and your day-to-day work.
Boost the Performance of Your WebGL Unity Games!
JS GameDev Summit 2023JS GameDev Summit 2023
7 min
Boost the Performance of Your WebGL Unity Games!
Unity, when deployed on the web, faces three critical challenges: build size, memory usage, and overall performance. This lecture delves deep into advanced optimization techniques to help you address each of these issues. Attendees will gain insights into:
- Effective strategies for optimizing textures, audio, and models.- A detailed analysis of our ASTC experimentation with Unity, shedding light on the unexpected results despite Unity's claims.- A comprehensive guide to Unity's memory profiling tool and its implications.- An exploration of lesser-known Unity settings that remain underutilized by many developers.
Additionally, we'll introduce our proprietary tool designed specifically for Unity optimization. We will also showcase CrazyGames' developer dashboard, our platform that enables developers to monitor and enhance the performance of their web-based games seamlessly. 
Join us to equip yourself with the latest strategies and tools to elevate your Unity web gaming projects.

Workshops on related topic

Make a Game With PlayCanvas in 2 Hours
JSNation 2023JSNation 2023
116 min
Make a Game With PlayCanvas in 2 Hours
Featured WorkshopFree
Steven Yau
Steven Yau
In this workshop, we’ll build a game using the PlayCanvas WebGL engine from start to finish. From development to publishing, we’ll cover the most crucial features such as scripting, UI creation and much more.
Table of the content:- Introduction- Intro to PlayCanvas- What we will be building- Adding a character model and animation- Making the character move with scripts- 'Fake' running- Adding obstacles- Detecting collisions- Adding a score counter- Game over and restarting- Wrap up!- Questions
Workshop levelFamiliarity with game engines and game development aspects is recommended, but not required.
PlayCanvas End-to-End : the quick version
JS GameDev Summit 2022JS GameDev Summit 2022
121 min
PlayCanvas End-to-End : the quick version
Top Content
WorkshopFree
João Ruschel
João Ruschel
In this workshop, we’ll build a complete game using the PlayCanvas engine while learning the best practices for project management. From development to publishing, we’ll cover the most crucial features such as asset management, scripting, audio, debugging, and much more.
Introduction to WebXR with Babylon.js
JS GameDev Summit 2022JS GameDev Summit 2022
86 min
Introduction to WebXR with Babylon.js
Workshop
Gustavo Cordido
Gustavo Cordido
In this workshop, we'll introduce you to the core concepts of building Mixed Reality experiences with WebXR and Balon.js.
You'll learn the following:- How to add 3D mesh objects and buttons to a scene- How to use procedural textures- How to add actions to objects- How to take advantage of the default Cross Reality (XR) experience- How to add physics to a scene
For the first project in this workshop, you'll create an interactive Mixed Reality experience that'll display basketball player stats to fans and coaches. For the second project in this workshop, you'll create a voice activated WebXR app using Balon.js and Azure Speech-to-Text. You'll then deploy the web app using Static Website Hosting provided Azure Blob Storage.