Jump to content

Is there any way to lower the weight impact from pixijs on final bundle?


Recommended Posts

Hello everyone, I'm suggesting using pixi (v5) for a component on a really bloated site, and its bringing too much weight to the final bundle. 
We don't need everything the library offers, so I was wondering if we can import what we need and maybe minimize the impact on the final bundle weight.

Has anyone encountered a similar issue? How did you manage it?

Link to comment
Share on other sites

Thank you! It did help!

Does this work if I use the npm package aswell? By importing only the things I use {Sprite} from @pixi/Sprite instead of importing * as PIXI from @pixi/core as a whole and doing something like PIXI.Sprite?

And also, as I need the PIXI instance for the gsap.registerPixi plugin, wouldn't I need to import the whole PIXI object?

Link to comment
Share on other sites

Look, the whole trick is to run the certain code before app starts

For that purpose, you have to create your own bundle file, that imports all stuff and exports PIXI.

Make sure it loads before your app starts rendering, this is necessary condition that webpack cannot guarantee. That is why we do things like that - we do not know all the ways users can create abomination that runs before our code runs.

1. Default way is to use "import {..} from PIXI"  everywhere - yes, that's enough.

2. Alternatively, include that bundle in APP  in that case you can use any imports directly from our @pixi/Sprite and other libs.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...