Optimization trick I found

So I’ve been having some real trouble with lag in my project(s) lately. There are literally so many blocks on the screen that it’s about a 50/50 chance that Snap! crashes my (school-issued) chromebook.

My teacher talked about block creation today, which prior to hearing about I hadn’t really touched yet, but it gave me a great idea! I’m not sure if this is common knowledge and I’m just now figuring this out, but by putting all of the blocks in a sprite into a single, or multiple, block heavily reduces the amount of lag whenever you load a page.

Ie:
THIS:

Gets turned into
THIS:

Although the window for the block will take a hot second to load, the tradeoff, for me, at least, is very much worth it.

You could skip this and put everything in a different sprite, but this can cause problems if you’re into making local vars instead of globally declaring everything.

If you want to see more examples of this, check out Snap! Build Your Own Blocks.

Hope this helps you!

This should low-key go into the Tutorials (Here's how to...) category

u so right faker sans

Bro what

So true!!!

Are people here mainly not from the US? I’m seeing a lot of views from what to me is tmrw

I’ve noticed this as well, and is probably one of the easiest optimizations you can do. It also encourages making blocks, which is a really big part of snap.

I low-key just do this for convenience, so that if I want to edit an important script, I can do it in any sprite

@da-ultimate-creater 's pfp is Sans from Undertale but obviously a snap user isn’t the real sans hence “faker” sans

faker sans is an au of sans

I don’t know, but they should really do a survey because those statistics would be interesting.

@bh

Help I can’t edit it

Good idea

Fixed!
Nvm, some fun-less guy flagged my post :(

They thought gathering demographics not related to Snap! is out of scope for this forum. I don't really know if this type of post is allowed, only we'll find out when a moderator officially declares the stance. Imagine posting a random survey not related to Snap! in a topic about an optimization trick. Wouldn't that appear a little bad form?

yes bro
on my own thread :sob: :sob:

Going back to the original topic, I actually found this made a major difference when I was doing Advent of Code. I had so many obsolete scripts (and large in-use scripts) that it froze Snap for one “not responding → wait” cycle just to open the sprite. Running the project with that sprite open slowed things down by a factor of 2 at least, and I was already dealing with 15-30 minute runtimes.