Loading indicator for the Worklight application

Our app's loading process is quite lengthy, so to keep the user informed that the app is indeed working and just needs time to load, we decided to implement a loading/initializing indicator. I initially attempted to use WL's busy indicator but found that it isn't fully available right at the start of the app's lifecycle. Instead, I opted to create a simple DIV within our single-page application to show the loading indication. When the app finishes loading, I hide the indicator. This method works well during the first run of the app, but subsequent runs exhibit different behavior.

First Run: The indicator appears immediately and disappears once the initialization is complete.
Subsequent runs: Initially, the indicator doesn't appear with the first presentation and only briefly flashes before the app finishes initializing and begins normal operation.

The loading DIV (I made this completely static without relying on any JS or CSS):

    <div id="loadingInd"
         style="z-index:1;position:absolute;left:85px;top:185px;display:block;">
         Loading2...
    </div>

Hiding code:

    $('#loadingInd').hide()

A bit about the loading process:

We preload all necessary JS and HTML files for the application. There are plans to switch to a more lazy loading process, but it's not high enough priority yet to be implemented. Once all files are loaded, we display UI elements such as menus and login buttons. Until everything is loaded, we have a loading splashscreen with the loadingInd DIV as static content. It's strange how the div shows up immediately during the initial run but delays appearing in subsequent runs. I suspect the flashing effect may be due to its timing with the call to hide(). Could there be something causing this discrepancy in drawing behavior during subsequent runs? I've checked the CSS information multiple times throughout the initialization process and everything seems consistent between the first and subsequent runs.


After some discussion here, I am going to give the busyIndicator another try. I will display it just before loading all content and hide it when it's time to load widgets. It seems to behave similarly to the DIV above. Perhaps there is an underlying issue related to drawing processes.

Answer №1

This code snippet was incredibly useful for my website. For those interested, check out a live demonstration on jsfiddle: http://jsfiddle.net/sYghV/4/

$(window).load(function() {
$("#pageLoadingMessage").fadeTo("fast", 0, function() {
      document.getElementById("pageLoadingMessage").style.zIndex="-100";
    });
});

Here's the HTML markup:

<div id="pageLoadingMessage"> 
<p style="top: 50%; position: absolute; left: 50%;">
<img src="http://sierrafire.cr.usgs.gov/images/loading.gif" style="width: 24px; height: 24px;">
</p> 
</div>

And the accompanying CSS styles:

#pageLoadingMessage {
background-color: gray;
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
z-index: 100;
text-align: center;
vertical-align: bottom;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Navigational link behavior in the React component with the <tr> element

I am in the process of developing a React application with a component that shares a resemblance to the following: class TableRow extends React.Component { constructor(props) { super(props) } render() { const handleClick = () ...

How to iterate through an array in jQuery/JavaScript and create variables in each loop?

I've been puzzled for a while now as to why this code snippet doesn't work as intended: if (longest.length >= 3) { for ( var i = 0; i < longest.length-1; i++) { var $last[i] = longest[i].splice(-1).toString(); //if ( $( $la ...

Tips for sending a string as HTML content in VueIn Vue, you can send a string as

I am attempting to pass the value for exp by using this code snippet. However, the form of selectedChannel.explanation appears as "channel name". Is there a way for me to display exp as channel name? computed: { channel: { get() { ...

Adjust the select box size to be in line with the text box dimensions

I'm struggling to understand why there are two boxes visible in my navigation bar. For example, when looking at the Home link, I notice that there are actually two boxes; one containing the text "Home" and another one that extends outwards to the rig ...

I seem to be missing something, as the client_id is required for Next Auth. What could it

I seem to be facing some confusion with where the communication breakdown is occurring. [...nextauth].js import NextAuth from "next-auth" import GoogleProvider from "next-auth/providers/google" export default NextAuth({ provider ...

Guide to showing the username on the page post-login

My MongoDB database is filled with user information. I'm looking to create a feature on the webpage that displays "Logged in as username here" at the top once users log in. My CSS skills are strong, but when it comes to JavaScript, I'm struggling ...

Utilizing Ruby interpolation to dynamically select elements in Capybara's CSS selectors

Having trouble with invalid selector errors when attempting to locate an element using capybara This method is successful: page.find("#widget_amount_Standard") But I encounter issues when trying any of the following: credit_type = "Standard" page.find( ...

What is the best way to redirect multiple paths in Express.js and consolidate them into a single outcome?

I typically make several .get requests, such as the following for notesController controller.get('/customers/', async (req, res, next) => { const customers = await Customer.find(); res.status(200).send(customers); }); controller.ge ...

I'm experiencing difficulties with Chrome loading jQuery and the SoundCloud API

Currently, I am facing a challenge in building a chrome extension where I cannot make API requests to SoundCloud or load Jquery successfully. I have identified the issue: When attempting to load jquery, I include the following script: <script src="// ...

Determine the total amount of pages generated from the Twitter search API

Can the Twitter search API provide a count of the pages returned? I'm curious if there is a method to determine how many pages are available for a particular query. ...

MEAN stack application that has an input field with a dynamic attribute which saves as undefined

How come the value for a dynamic attribute is showing up as "undefined" in my form? I initially thought it was related to a hidden input, but the issue persists even when the input is not hidden. When trying to save a new event, I want the user to be able ...

How come my search query in the input form is unable to locate a user in the table?

I am currently facing an issue with my PHP search functionality. I have a table called "users" and I want to find the user that matches the name inputted by the user and display it on the screen. However, for some reason, the program is not displaying the ...

Implementing Content-Security-Policy with React and Material-UI v4 for secure styling requirements

Utilizing a React UI with material-ui version 4, the web server is embedded within a JVM application during Production. Following npm build for the UI, the bundle is deployed alongside the server side code. An essential requirement involves implementing C ...

Executing a function when a webpage loads in Javascript

I have created a responsive website using Twitter Bootstrap. On my site, I have a video displayed in a modal that automatically plays when a button is clicked. Instead of triggering the function with a button click, I want the function to be called when ...

How can I create an element in Javascript that does not inherit any CSS styles?

I'm creating a basic userscript with Greasemonkey for a school project that inserts a bright yellow box containing links onto all websites. Currently, my approach is straightforward: var guesses_div = document.createElement("div"); guesses_div.style. ...

What are some ways to adjust the size of the option field in a select menu?

In my ionic popup, I have a HTML property called select with nested options. Below is the code snippet along with the applied CSS. My query is how can I set the white space to occupy the entire area of the select? https://i.stack.imgur.com/iPqAa.png http ...

How to Use Google Calendar API to Retrieve Available Time Slots for a Given Day

Is there a way to extract the list of available time slots from my Google Calendar? Currently, I am only able to retrieve the list of scheduled events. I am utilizing the Google Calendar npm package. google_calendar.events.list(calObj.name,{ timeMin ...

Having trouble binding component property in VueJS with TypeScript?

Why is my component property not binding when I set the related component attribute to a value? Even when inspecting with Vue devtools or outputting the value into the HTML, it remains at the default value set on the component. I tried setting a string at ...

The Javascript regex allows for the presence of positive and negative numbers, with the option of a single minus symbol

oninput="this.value = this.value.replace(/[^-0-9.]/g, '') This code snippet is utilized in my current project. However, there seems to be an issue where the input can contain more than one minus sign, as shown here: ---23 To address this p ...

The property of undefined map cannot be read

import React from 'react'; import { Card, Text } from "react-native-paper"; import { SafeAreaView, } from "react-native"; class HackerNewsClone extends React.Component { constructor(props) { super(props); this.sta ...