Innovative JavaScript and CSS Progression for Internet Explorer 6 with Two Layers

I am attempting to dynamically load JavaScript (and CSS) files into a webpage in the following order: index.html -> loader_a.js -> a_foo.js, a_bar.js, a_foo.css, and so on. While this process works seamlessly in Firefox using appendChild, I am encountering issues making it work in IE6.

Despite trying various suggested solutions such as adding to DOM node, AJAX call and eval from sources like here, there, and other forums like post #2013676, the scripts are not executing as expected.

DebugBar shows that the include files (e.g., a_foo.js) are being loaded but their content is empty - direct/included files at one level display the content correctly, suggesting there may be an issue with the hierarchy of loading.

The error message I consistently encounter is 'undefined object,' indicating that the function I am calling is not properly loaded, offering little help in resolving the problem. There are no errors reported during the includes process, and JS validation confirms the scripts are correct.

If anyone has a foolproof solution to this issue, it would be greatly appreciated. I can provide additional code snippets if necessary.

Thank you, Best regards, Thomas

Sample HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<HTML lang=en><HEAD><TITLE>Test</TITLE>

<script type="text/javascript" src="mmtest_files/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="mmtest_files/multiload.js"></script>
<script type="text/javascript" >

function init2() {
  // using the data from the loaded js files
  var a= mmf("a");
  document.getElementById('status').innerHTML = "Variable set:" + a;

}

// magic...
include(['mmt.js'],init2);

</script>

<BODY >

<H2>Test me!</H2>
<SPAN id=status>status old</SPAN>

</BODY></HTML>

JS 1 refers to multiload from answer 1

JS2 is a test include:

function mmf(param) { return "Called with" + param; }

Answer №1

To achieve parallel script loading in Internet Explorer, it is recommended to utilize the document.write method.

For more information, refer to: Loading Scripts Without Blocking

You can find a script that accomplishes this here: Loading Multiple Javascript Files In Order Asynchronously

(Please note that some enhancements may be required for Chrome browser)


UPDATE

A callback function is available and optional. It can be used to link dependent scripts with the loaded files. For example:

function myjQueryCode() {
   // ...
}

include(['jquery.js','jquery-ui.js'], myjQueryCode);

This allows your jQuery dependent code to execute after the files have been successfully loaded.

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

The issue with Firebase's real-time database is that data constantly gets overwritten within a single node

Having an issue with writing data to my Firebase realtime database. Below is the code I am using: firebase.database().ref("ac/0/").set(null); firebase.database().ref("ac/0/").once('value', function(snapshot){ for(var i=0; ...

Troubleshooting Node.JS body parsing problems

I am struggling to transmit data from one machine to another using node.js. I am facing some challenges with getting the parser to work properly. Below is my client and server code: Client.JS var request = require('request'); request.post( ...

What is the most efficient way to retrieve key pair values of separate elements in an array with just one API request?

The API I am working with returns an array of elements, each containing multiple key-value pairs. An example of a similar API response can be seen here: , where an array of poems is returned. [ { "title": "...." "content": "..." "url" : "..." } ...

Utilize CSS styling on dynamically loaded HTML content

I am working on a project similar to the StackOverflow editor. I am fetching markdown text, converting it to HTML, and then displaying it in a preview area. However, when I try to style the injected HTML elements using CSS, the styles are being ignored. Up ...

Adding a margin space to the right of the header using Bootstrap

As I embark on creating my very first Bootstrap website, I have encountered what seems like a simple issue that is causing me quite the headache. There appears to be an unexplained 20px margin on the right-hand side of the page, persisting across all brows ...

Utilize jQuery to set a cookie, then apply the bodyclass retrieved from the cookie upon page

I have a button that changes the body class to .blackout For this, I am utilizing js-cookie library to manage cookies. The code snippet associated with my button is shown below: <script> $('#boToggle').on('click', function(e) { ...

I am facing some issues with the React ToDoList project

I'm a student trying to create a ToDoList using React. When I try to submit or remove a schedule, nothing happens and the lists are not updated as expected. However, if I type something in the submission box, it works! I can't seem to figure ou ...

Attempting to dispatch data from Vue.js event bus

I am attempting to increase the count of quotes by one and also add the text from a textarea to an array. While the text is successfully added to the array, the number of quotes always remains zero. I have tried combining the two actions in one method as w ...

Having trouble connecting angular repository data with promise

I have been trying to implement the repository pattern in my Angular application. I can see that the JSON data is successfully retrieved over the network when I call my repository, but I am facing issues with binding it to my view. I have injected the rep ...

display angular filter for mat radio option selected from mat-radio group

On the screenshot provided below, there are 2 buttons within a mat radio group. The condition is that if modelForm.get('schedule').value equals '1', then only display the radio button with the value 'A'. Otherwise, show all va ...

Loading New Content in a Bootstrap Card with Navbar: A Guide on Updating Content without Refreshing the Page

Working with Django in the creation of a basic website, one specific page named analysis.html is utilized to access data from the Twitter API. Within the analysis.html file, there exists a card sourced from Bootstrap's components: <div class="car ...

What is the best way to convert a date to ISO 8601 format using JavaScript? Are there any built-in functions or methods in

Currently, I am using this function to set the duration: const setDuration = () => { const currentDate = new Date(); const newDate = new Date(currentDate.getTime()); const year = newDate.getUTCFullYear(); const m ...

The Mat-paginator is refusing to align to the right edge when scrolling the table horizontally in an Angular application

https://i.sstatic.net/l0cZ4.png Overview: My Angular component features a table with Angular Material's mat-table and paginator. Despite fetching data from a source, the paginator fails to float right when I scroll horizontally. Sample Code: <!- ...

Tips for displaying a JSON array on a web browser using a React component

My goal is to display a list of JSON data obtained from an API on the browser. I have successfully fetched the data from the REST API in the backend and now need to render it on the browser. Here is what I have learned and attempted: import React from &ap ...

Leveraging the async library in Node.js to execute multiple tasks in parallel by passing an array

In the code snippet below, there is a function that fetches data in parallel. After the data is fetched, the result can be accessed through the 'results' variable in the callback function. Instead of hard coding 'products', 'images ...

Ensure that the cursor is consistently positioned at the end within a contenteditable div

I'm working on a project where I need to always set the caret position at the end of the text. By default, this works fine but when dynamically adding text, the caret position changes to the starting point in Chrome and Firefox (Internet Explorer is s ...

Guide on integrating an event in Angular 4 to an HTML element inserted using an external library

Recently, I integrated the jQuery wizard library into my project to streamline user interactions. One of the key features it provides is automatically adding next and back buttons to guide users through the wizard process. You can find more information abo ...

Looking to update the background color of a div every 3 seconds?

Every 3 seconds, I need to change the background color of each div. To do this, I attempted to modify the values in the color array every 3 seconds. For example, the value at index 0 (which is "red") would move to index 1, then the value at index 1 would ...

What are the steps for utilizing the skrollr library to manipulate text within a div without it being

I'm a beginner in html, css, and javascript and I'm trying to create my first one-page website using the skrollr library. However, I'm facing an issue where the content in my second div is not displaying properly and is hidden behind the fir ...

Can you tell if there are any distinctions between the two code snippets?

Initial Code console.log('Begin'); // output 1 await axios({ method: 'post', url: '<HTTP_URL>' data: <SOME_DATA>, }).then ((response) => { // Performing some action... This may take a few seconds. con ...