Enhancing the PreLoadMe script to cater to browsers that have JavaScript disabled

Greetings everyone, I have implemented this script (created by Niklaus Gerber) successfully, but there is a small issue. Upon setup, it initially covers the entire page with a div using CSS styles. Then, the script reveals the fully loaded site as intended, but it causes browsers with disabled JavaScript to experience infinite loading.

Does anyone have any suggestions on how to address this problem and make the website more user-friendly for those individuals? (Note that the website is not live yet).

Here is the code snippet:

    $(window).load(function() {
        $('#status').fadeOut();animation
        $('#preloader').delay(350)\.fadeOut('slow');
        $('body').delay(350).css({'overflow':'visible'});
    })

Here is the HTML structure:



<div id="preloader">

    <div id="status">&nbsp;</div>

</div>

And here are the relevant CSS styles:



body {

    overflow: scroll;
}

#preloader {

    position: fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background-color:#fff;
    z-index:99;
}

#status {

    width:200px;
    height:200px;
    position:absolute;
    left:50%;
    top:50%;
    background-image:url(../img/status.gif);
    background-repeat:no-repeat;
    background-position:center;
    margin:-100px 0 0 -100px;
}

Thank you in advance for any advice or suggestions.

Answer №1

Here is a straightforward solution to try out:

To implement it in your JavaScript, simply include $('body').addClass('jsSupport');

Additionally, you can set up your CSS to initially hide the preloader, preventing it from displaying when JavaScript is disabled.

#preloader{
  display:none;/*hidden without js*/
}

Once JavaScript is enabled, customize the appearance by adding an extra CSS class.

.jsSupport #preloader {

    display:block;/*display with js support*/
}

For a live example of this code implementation, take a look at the demonstration located here.

To test functionality, feel free to turn off JavaScript within your browser using the full-screen demo accessible here.

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

Django: Hosting CSS on S3 with accurate URL, yet failing to load

My STATIC_URL is configured to point to the URL of my S3 bucket and the static directory within it. STATIC_URL = 'https://s3.amazonaws.com/XXXXXXX/static/' When I try to load the stylesheets in my template using: <link href="{{ STATIC_URL } ...

The link that has been clicked on should remain in an active state

Is there a way to make the link that is clicked on active? I have attempted various scripts but have had no luck in getting the desired effect. Can anyone identify what might be causing the issue? $("a").click(function () { if ($(this).hasClass("acti ...

Animation for Images in Angular v1.2

After reviewing tutorials and previous questions, I have been trying to pinpoint where my code is going wrong in applying an animation to transition between the images I want to display. The ng-show function effectively displays the selected picture, but ...

Methods for Hiding and Revealing a UIView with the Press of a Single UIBarButtonItem

In my iOS app, I have created a right bar button item programmatically and added it to my view controller. Additionally, I have also added a UIView to the view controller. The action for my bar button item has been set. Currently, the UIView is hidden when ...

Exploring JSON Object Iteration Using jQuery for AJAX Requests in JavaScript

I am struggling to grasp this concept. Currently, I have a JSON file that contains a collection of hospitals, including their addresses, operating hours, and phone numbers. My goal is to make an AJAX call to retrieve data from the JSON file and display i ...

Adjust the CSS button size to match the HTML border dimensions

As I work on my website, I have created buttons and used CSS to adjust the padding in order to make them equal in size. However, I am now curious if there is a way to dynamically size the buttons to fit within the table border for a consistent look across ...

The alignment of items to the top, center, and bottom is experiencing difficulties

I am facing an issue with positioning elements within a div. The layout consists of an image on the left, followed by information on the right (a span, an h3, and another span). My goal is to align the first span at the top, center the h3, and position the ...

Issues with Videojs Responsive Lightbox Functionality

I am looking for a solution to display VideoJS in a lightbox while keeping it responsive. I came across this helpful code snippet: https://github.com/rudkovskyi/videojs_popup. It seemed perfect until I tried using it with the latest version of Videojs and ...

How to verify if a node contains plaintext with jsoup?

Is there a way to determine if a node in jsoup has plain text without including link text, instead of using the Element.hasText() method? Any suggestions would be greatly appreciated. Thank you ...

Enhance your slider experience: Applying a class name during the transition from left to right and right to left on S

How can I differentiate between left to right (ltr) and right to left (rtl) movements in a slick slider? I am looking to add unique class names for each direction movement. Can anyone help me with this? Feel free to comment if you need more information. ...

Converting an object into an array in JavaScript for the purpose of adding an item to it

Looking to update a data object by adding a new item? Convert the object into an array, add the item, and then switch it back to an object to achieve that. Here's the initial data object: { Activity: 'digitalLoan', digitalLoan_type: &ap ...

Creating a line of functions pool in Javascript with a delay feature

Recently, I created a code snippet that simulates a function line. It involves calling functions such as fn1, delay, fn2, delay, and so on. The idea is to call a function, remove it from the line, have a short sleep, and repeat. However, I've encount ...

Retrieve the header tag from API using Nuxt

I am trying to dynamically set OG:Tags using an API head() { this.$axios .get(`............`) .then((response) => { this.og_title = response.data.message.course.course_name; this.og_description = response.data.message.course.description; ...

Navigating the right URL using Aurelia in conjunction with .Net Core and an IIS web application

Running my Aurelia app under Asp MVC Core 1.0 presents a challenge when deploying to IIS. The app uses HttpClient to interact with controller actions that return JSON data. All the actions are in the Home controller, and the HttpClient is configured like t ...

What is the best way to transfer data between windows using titanium (classic)?

'The code I've written utilizes MyHTTPlink to retrieve information such as Restaurant Name, url, and address. Currently, it lists all restaurant names and urls in a table. Now, I want to figure out how to send the details of a table row to the ne ...

Interacting with Vue3 List Items by Manipulating the HTML DOM

I am currently using Vue 3 and I have a requirement to manipulate a specific list item when a button is clicked. Below is the HTML code snippet: <socialDiv v-for="(follower, i) in followerList" :key="follower.id" :ref="el => ...

Is there a way to retrieve an HTML index from the provided HTML data using Selenium with Python?

As a newcomer to selenium, I am eager to click on collapsed tabs within dynamic websites. Currently, I am utilizing //a[@href[contains(.,"Text")]] to search for specific text on the page. In a scenario where I retrieve 3 tags containing the desired text ...

Use CSS to configure the mouse wheel for horizontal scrolling

Looking to create a horizontal page layout, but when I scroll with the mouse wheel the content only moves vertically. Is there a way to enable horizontal scrolling using the mouse wheel? Does CSS have a property for this? For instance, is there something ...

Prevent additional clicks on the image

Currently, I am dealing with a situation where I have a list containing a jQuery handler for mouse clicks. The dilemma is that I need to insert an image into the list, but I want clicking on the image to trigger a different function than clicking elsewhere ...

Understanding JSON Parsing in Jade

I am facing a challenge with handling a large array of objects that I am passing through express into a Jade template. The structure of the data looks similar to this: [{ big object }, { big object }, { big object }, ...] To pass it into the Jade templat ...