Why invoke the Phaser.Game function twice?

In some Phaser code examples I see, there is a call like this in the HTML where the canvas element is stored:

var game = new Phaser.Game(800, 600, Phaser.AUTO, ‘canvasname’, { preload: preload, create: create, update: update });

And then often the exact same call is made in a required JavaScript file, such as game.js, and the game is booted and drawn.

What is going on here? Why call it twice?

I think I understand that the game.js literal is binding the HTML canvas, but I don’t understand why this doesn’t call the Phaser.Game constructor twice… Or does it?

Any advice is appreciated.

Which examples are you referring to? Each new Phaser.Game will create an independent game instance, which you of course only want one of. I can’t think of anything that could be confusing you, so the best course of action would be to actually look at the example.

Well I think this answers my question that there should be one call. I downloaded someone else’s code and was looking at it trying to understand it but now I think I should stick to official examples.

My plan then is to put the Phaser.Game call in the js file only and not in the HTML.

Thank you