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!

  • 3
    \$\begingroup\$ Can submissions wait 0.25 seconds before initially displaying output? \$\endgroup\$ – ETHproductions 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

93 Answers 93

1 2 3

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

Rust, 117 Bytes

print!("Loading... ");fn f(){let a="\\|/-";for n in 0 .. 4{std::thread::sleep_ms(250);print!("\x08{}",a[n]);}f();}f;

Fixed some compile errors. Nowhere near a compiler right now so bear with me.

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.