Your challenge is to make an infinite loading screen, that looks like this:

enter image description here

Or, to be more specific:

  • Take no input.
  • Output Loading..., with a trailing space, but no trailing newline.
  • Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can overwrite just the last character, or delete and rewrite the whole line, as long Loading... remains unchanged.


  • The output text must look exactly as specified. Trailing newlines/spaces are acceptable.
  • You should not wait 0.25 seconds before initially showing output - the first frame should be printed as soon as the program is run.
  • Your program should be able to run indefinitely. For example, if you use a counter for frames, the counter should never cause an error by exceeding the maximum in your language.
  • Although the waiting period between each "frame" should be 0.25 seconds, obviously this will never be exact - an error margin of 10% or so is allowed.
  • You may submit a function, but it must print to stdout.
  • You can submit an answer in a non-console (but still text-based) environment, as long as it is capable of producing the loading animation.
  • This is , so the shortest solution (in bytes) wins. Standard code-golf loopholes apply.
  • If possible, please provide a gif of your loading screen in action.


Here is the C++ code I used to create the example (ungolfed):

#include <iostream>
#include <string>
#include <thread>

using namespace std;

int main() {
    string cycle = "|/-\\";
    int i = 0;

    cout << "Loading... ";

    while (true) {
        // Print current character
        cout << cycle[i];

        // Sleep for 0.25 seconds

        // Delete last character, then increase counter.
        cout << "\b";
        i = ++i % 4;

May the best golfer win!

  • 4
    \$\begingroup\$ Can submissions wait 0.25 seconds before initially displaying output? \$\endgroup\$ Nov 27 '16 at 20:42
  • 2
    \$\begingroup\$ No, but thanks for mentioning that, I'll add it to the rules @ETHproductions \$\endgroup\$
    – FlipTack
    Nov 27 '16 at 20:43
  • \$\begingroup\$ Is a trailing newline (after the animating symbol) acceptable? \$\endgroup\$
    – Copper
    Nov 27 '16 at 20:43
  • \$\begingroup\$ Of course :) @Copper \$\endgroup\$
    – FlipTack
    Nov 27 '16 at 20:44
  • 1
    \$\begingroup\$ @TheBitByte it means that, theoretically, nothing inside your program will cause it to error - such as a counter overflowing or reaching maximum recursion depth. \$\endgroup\$
    – FlipTack
    Dec 15 '16 at 6:57

95 Answers 95

1 2 3

><> with -t.03 flag, 33 bytes

'o!vooooo|\-/ ...gnidaoL

Try it online!

The only part of the specification this doesn't implement is that the first frame should be printed as soon as the program is run which seems rather strict and unobservable. The first frame here take 1.08 seconds to print, and every frame after that takes 0.24 seconds.


Yabasic, 83 bytes

An anonymous function that takes no input and outputs to the console in graphics mode. Does not function with TIO.

Clear Screen
  • \$\begingroup\$ Can you use i instead of i+1 in Mid$? \$\endgroup\$
    – 12Me21
    May 17 '18 at 11:55
  • \$\begingroup\$ @12Me21 Unfortunately not - Mid$ is 1-indexed in Yabasic, so the +1 is necessary. You can see this in the context of this question here \$\endgroup\$ May 17 '18 at 12:43

Groovy, 60 bytes 59 bytes, 61 bytes

print'Loading...';for(;;)'|/-\\'.any{print"$it\b";sleep 250}

(modified to work with later versions of groovy, removed ascii cast)


Stax, 24 bytes


Run and debug it

Delays 15 frames between each change, which at default 60fps should be equal to 1/4th of a second.


W                             loop forever
 `lAtv>!`                     push "Loading... "
         "|/-\"{            F for each char in "|/-\"
                [+p           add to Loading and print
                   {|,}15*    delay 1 frame 15 times
                          |:  clear the screen
  • \$\begingroup\$ limiting your display to 30fps would mess with any of the programs here. \$\endgroup\$
    – Razetime
    Jun 10 at 2:57
  • \$\begingroup\$ Hm. An error margin is allowed, and no fps requirements are specified. It should work fine on any modern browser. \$\endgroup\$
    – Razetime
    Jun 10 at 3:00
  • \$\begingroup\$ I will specify a 60fps browser requirement then. \$\endgroup\$
    – Razetime
    Jun 10 at 3:03
  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$
    – Razetime
    Jun 10 at 3:05

05AB1E, 26 bytes

[13甲½... ”"|/-\"NèJ?Ƶ–.W

[13ç”...”"..."NèJ?Ƶ–.W  # trimmed program
[                       # forever...
   ç                    # push character with codepoint...
 13                     # literal
    ”...”               # push "Loading... "
               è        # push character in...
         "..."          # literal...
               è        # at index...
              N         # current index in loop...
               è        # modulo length of...
         "..."          # literal
                 ?      # output...
                J       # joined stack...
                 ?      # without trailing newline
                    .W  # wait...
                  Ƶ–    # 250...
                    .W  # milliseconds
1 2 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.