Why Isn't Phaser.js Able To Load An Image From A Third-party Domain?

- 1 answer

I'm learning phaser.js, and I cant even load the image.

Here is the code:

// Need state. All game logic goes in state

var GameState = {

    // Load all your images. Thats what the preload function is
    preload : function(){
        //Load Image
    this.load.image( 'background', '' );


    //Execute after everything is loaded
    create: function(){
        //From top left param = (x,y)
        this.background =,0, 'background');


    update: function(){



// New Game instance, 3rd parameter WEBGL or CANVAS automatic  GL
var game = new Phaser.Game(640,360,Phaser.automatic);

// add state to game

// First just a name, second par is the actual Object
game.state.add('GameState', GameState);

And here is the image that clearly shows that it doesen't load:

enter image description here



Your image isn't showing up because Phaser can't make use of cross-origin images, so all images need to be loaded from the same origin. In practice, this means that instead of loading the image directly from, you need to first download the image to your computer, then move it to your Phaser project folder and load it using a relative path.

For more information, please see the Wikipedia article on the Same-Origin Policy.