Skip to content

Instantly share code, notes, and snippets.

@adam-binks
Created March 3, 2022 16:47
Show Gist options
  • Save adam-binks/a592008c45f781c144e76ce916c73316 to your computer and use it in GitHub Desktop.
Save adam-binks/a592008c45f781c144e76ce916c73316 to your computer and use it in GitHub Desktop.
Generate GuidedTrack code to invisibly load all a program's images on its first page, so that they load instantly on later pages
# NB: you may need to convert tabs to spaces when you copy it into your GT program
gt_program = r"""copy and paste your program here>"""
lines = gt_program.split('\n')
images = []
for command in ["*image: ", "\t\t*picture: "]:
images.extend([line[len(command):] for line in lines if line.startswith(command)])
print(r"""
*html
<style>
.imagesToPreload {
display:none;
}
</style>
*component
*classes: imagesToPreload
""")
print("\n".join("\t*image: " + image for image in images))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment