Is there any way to check either jquery, jquery.ui and dependent plugins load or still in downloading ?
I mean jquery plugin must be loaded first then jquery.ui plugin should be loaded and after then all other dependent plugins should be loaded and work.
I need to load these in a sequential orders.
and I want to see the conflicts as well.
Actually I have developed a widget in Asp.Net MVC Core 6 and the users of my widget are third parties. Many of the users of my widget are already using jquery and jquery.ui plugins in their application. My widget is a part which should work everywhere.
@page "/c-index"
@inject IConfiguration Configuration
@model CarWidget.Views.Home.MainPageModel
@{
string fullUrl = @Configuration["CustomSettings:LiveUrl"];
string fullUrl = "";
if (!string.IsNullOrWhiteSpace(isLocal) && isLocal.ToLower() == "live")
{
fullUrl = liveUrl + baseName + "/";
}
else
{
fullUrl = localUrl;
}
}
@section Scripts{
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"
integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg=="
crossorigin="anonymous" referrerpolicy="no-referrer" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"
integrity="sha512-uto9mlQzrs59VwILcLiRYeLKPPbS/bT71da/OEBYEwcdNUk8jYIy+D176RYoop1Da+f9mvkYrmj5MCLZWEtQuA=="
crossorigin="anonymous" referrerpolicy="no-referrer" ></script>
<script src="@(fullUrl + "lib/mbExtruder/mbExtruder.js")></script>
<script src="@(fullUrl + "lib/apis/commondata.js")" asp-append-version="true"></script>
<script src="@(fullUrl + "lib/apis/responsive-tabs.js")" asp-append-version="true"></script>
<script src="@(fullUrl + "lib/apis/searchbycodeorlocation.js")" asp-append-version="true"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script type="text/javascript">
//var jq = jQuery = jQuery.noConflict();
jQuery.noConflict();
</script>
}
Thank you for the guidence.
Now I am trying to add in the following way:
var jQuery;
loadJquery();
/******** Load jQuery if not present *********/
function loadJquery() {
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '3.5.1') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
"https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
scriptLoadHandler();
}
};
} else {
script_tag.onload = scriptLoadHandler;
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
jQuery = window.jQuery;
}
}
/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
// Restore $ and window.jQuery to their previous values and store the
// new jQuery in our local jQuery variable
jQuery = window.jQuery.noConflict(true);
// Call our main function
loadJqueryUI();
}
function loadJqueryUI() {
debugger;
if (window.jQuery && window.jQuery.fn.jquery === '3.5.1') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
"https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
loadJquerymbExtruder();
}
};
} else {
loadJquerymbExtruder();
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
//jQuery = window.jQuery;
}
}
function loadJquerymbExtruder() {
debugger;
if (window.jQuery && window.jQuery.fn.jquery === '3.5.1') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
'@fullUrl' + "lib/mbExtruder/mbExtruder.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
loadJqueryCommonData();
}
};
} else {
loadJqueryCommonData();
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
//jQuery = window.jQuery;
}
}
function loadJqueryCommonData() {
debugger;
if (window.jQuery && window.jQuery.fn.jquery === '3.5.1') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
'@fullUrl' + "lib/apis/commondata.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
loadJqueryResponsive();
}
};
} else {
loadJqueryResponsive();
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
//jQuery = window.jQuery;
}
}
function loadJqueryResponsive() {
debugger;
if (window.jQuery && window.jQuery.fn.jquery === '3.5.1') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
'@fullUrl' + "lib/apis/responsive-tabs.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
loadJquerysearchbycode();
}
};
} else {
loadJquerysearchbycode();
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
//jQuery = window.jQuery;
}
}
function loadJquerysearchbycode() {
debugger;
if (window.jQuery && window.jQuery.fn.jquery === '3.5.1') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src",
'@fullUrl' + "lib/apis/searchbycodeorlocation.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
//scriptLoadHandler();
}
};
} else {
// script_tag.onload = scriptLoadHandler;
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
//jQuery = window.jQuery;
}
}