Issue with bxSlider not initializing correctly upon initial loading in Chrome browser

After implementing bxSlider on my website following the instructions from this page, I encountered an issue where the slider arrows would display on the first load but the images themselves would not appear.

Interestingly, upon a second load (refreshing the page), everything worked perfectly fine. This peculiar problem seems to be isolated to Chrome.

Other browsers such as Edge, Firefox, and IE have no trouble displaying the slider images on the initial load.

While the provided snippet works flawlessly, I'm unable to replicate the problem within it. Here is a link to the actual page: click here. Although MVC does not prefer external links, I am puzzled by this behavior. Could this be a Chrome bug that has no immediate fix?

I also made use of version jquery/1.11.0 for my site, which aligns with the resources used in the code snippet below. It appears that the issue may not be related to the jQuery version either.

<html>
<head>

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script>

  <script>
    $(document).ready(function(){
      $('.slider').bxSlider();
    });
  </script>

</head>
<body>

  <div class="slider">
    <div>I am a slide.</div>
    <div>I am another slide.</div>
  </div>

</body>
</html>

Answer №1

It appears that the initialization function $('.slider').bxSlider() is being called before the bxslider.js script has finished loading...

To address this, consider initializing your $('.slider').bxSlider() function after the page has fully loaded using $(window).on("load")

$(window).on('load', function() {
  $('.slider').bxSlider();
})

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

A method for conditionally looping to match header rows with data rows in a map

When dealing with two types of rows: header rows and data rows, each consisting of 18 columns. The number of data rows is determined by the number of header rows, for example: If there are 2 header rows, there should be (2 data rows: first one maps to th ...

Implementing Interactive Click-Activated Highlighting for jQuery Map

Currently, I am working on creating diagrams utilizing the jQuery Highlight Plugin found at http://davidlynch.org/js/maphilight/docs/. The diagram I have created is clickable, allowing content to load based on the specific area that is clicked (similar to ...

Display a div in front of another using Material UI when hovering

Is there a way to display a black transparent div in front of a <MediaCard/> when hovering over it? Below is the code snippet I am using with Material UI: <Box> <Typography variant='h3'>Home Page</Typography> < ...

Is there a way to retrieve information from an external URL in JSON format and display it using JavaScript on a separate HTML webpage?

I'm trying to display the value TotalPostNotificationCount from a JSON file in an external HTML using either JavaScript or PHP. The JSON data is as follows: { "DayPostCount": 1, "TotalPostNotificationCount": 7381 } This data can be found at t ...

Disable automatic scrolling in WKWebView when a user selects text

When a user taps and holds to select a word, then moves their finger towards the top or bottom edges of the screen, the page automatically scrolls to adjust for the selection. Watch a short clip demonstrating this I am looking to disable this behavior wi ...

Retrieving multiple entries using a single query

Hello everyone, I have a question for you all. UPDATE `talent2db`.`talent_employee` SET `Rec_Status` = 'I' WHERE `talent_employee`.`Emp_Id` = '241074' AND `talent_employee`.`Rec_Status` = 'A' ; UPDATE `talent2db`.`talent_emp ...

The dialog box in CSS is extending too far down past the bottom of the screen, making it impossible to scroll and click on the buttons located

I am currently working on creating a dialog box with a text area using material UI. Unfortunately, when I input a significant amount of text, the dialog box ends up extending beyond the screen, making it impossible to scroll down to access the buttons. &l ...

Error specific to IE when using $.getJSON

Implementing a for-loop to fetch multiple database entries from the server, I created a code snippet that functions correctly, HOWEVER: Interestingly, this code does not work properly on IE11. While it runs smoothly on Google Chrome, Firefox, Safari, and ...

Tips for creating responsive images when using two images stacked on top of each other:

One of my challenges with using Bootstrap is trying to place an image on top of another image. Here's the HTML code I currently have: <section id="test"> <div class="row"> <div class="imgbg"><img src="img/bg_pres.png ...

The jQuery "form-row" for dynamic input generation in Bootstrap is experiencing technical difficulties

When I click the Add Wings/Blocks button, dynamic fields are created using jQuery which are Bootstrap components. I want to arrange 3 fields from (left to right) in a single row. Although I have written code for it, the "form-row" is not arranging the fie ...

Mobile Day Scheduler Calendar - Organize Your Day on the Go

Currently in the process of developing a mobile website and looking for a daily scheduler similar to the one found at http://arshaw.com/fullcalendar/ (specifically with an hourly scheduler) The key requirement is that it must be optimized for mobile devi ...

Is it possible to locate the Bower configuration file in Debian if running as root?

Hey there, I've been trying to execute a "bower install" command on a project I'm working on, but unfortunately, I keep running into an error. Error details: Since bower is a user command, it shouldn't be run with superuser permissions. If ...

What is the process for incorporating a custom button for selecting the date and closing the calendar in bootstrap-datepicker?

I successfully coded a simple project, but I'm struggling to figure out how to add a custom button to the bootstrap-datepicker. <!DOCTYPE html> <html> <head> <title>JS</title> <link rel="stylesheet" href="http ...

Passing JSON data from template to view in Django

I'm facing an issue with sending JSON data via AJAX from the template to the view and storing it directly in the database. The problem lies in the data not reaching the view successfully. When I try to insert my JSON data (json_data['x'], js ...

What is the best way to assign a title to every div element and showcase 5 div items in a single line?

I am using a "for loop" to call getjson multiple times and receive a response to display items on sale inside a div. Currently, my code displays the item name to the right of each frame, but I want the item name to appear below the iframe, similar to the c ...

"Selecting the hue of an image on an input

Is it possible to easily incorporate color images into a design? I am struggling to find the property that will allow me to do so. There is a button that contains an image. .button { background: url('../image/arrow.png') 189px no-repeat ...

Matching Figures to their Descriptions

I am currently working on a website and looking to include images with captions that display the price of each item underneath. The issue I'm facing is that the captions are aligning horizontally instead of vertically. Can anyone provide assistance wi ...

Tips for making nested sliding divs within a parent sliding div

Is it possible to slide a float type div inside another div like this example, but with a white box containing "apple" text sliding inside the black div it's in? I have attempted to recreate the effect using this example. Here is my current JavaScript ...

Sending a PHP object as the value of an HTML radio button

When dealing with a custom object that needs to be passed as a form value in a radio button selection, the usual method involves invoking the toString() function on the object. However, this simply converts the object to a String, which may not be ideal fo ...

Choose from a dropdown menu with the possibility of selecting zero, which does not adhere to the default value

I'm facing a minor issue with a select list. Here's the code snippet: <div> <label>Label Title:<span class="text-danger">*</span></label> <select class="form-select" asp-for="Model ...