As has been discussed at breadth in many a forum, it is recommended to use Google's CDN for loading common js libraries. I am doing the same in my app and am loading jquery and jquery-ui from the Google cdn.
Now there have been quite a few instances where users have reported broken UI and that is a result of jquery ui not firing. e.g. jquery UI tabs/progress bars not working. Now I am wondering why this is happening and most probable reason seems to be jqueryui not getting downloaded properly from Google CDN.
Has anyone faced similar issues before? How to ensure that juqeryui is initialized/ready for each user?
There are some fallback solutions (for jQuery proper) in this answer that may be helpful.
This one in particular.
Related
I have a client who had a very complex jQuery app custom built by a previous developer within his WordPress site. Its functionality is cleanly broken out into several scripts which get minified together with the libraries they depend on. The libraries rely on an old version of jQuery (3.3.1). The site is complex and we need to be able to use the current version of jQuery to allow other plugins we're using to continue to keep up with upgrades.
The libraries include c. 2018 versions of:
Select2
Isotope
SpriteSpin
EasyResponsiveTabs
ImagesUploaded
jQuery Viewport
Some of these are minified/uglified.
I've used best practices to load jQuery 3.3.1 into a variable jQuery3_3_1 with noconflict();
It's rather easy to change standard jQuery to use jQuery3_3_1. But I need a way to force the libraries to use jQuery3_3_1, otherwise they are not recognized by the scripts (and some of them will have issues using a different version of jQuery than they were built in). Most of these use requireJs(), and I've seen instructions for setting up requirejs.config() code in the footer that will define "jquery" to be a particular version. Doing this would be a great solution, but I have no idea how to get these uglified scripts to use it.
I've read through several similar inquiries, but none have addressed forcing a jQuery version on minified/uglified code. Others speak to a level of expertise in jQuery module development that I don't have and don't have time to scale into.
Is there a way to get all these modules that use require('jquery') to have that reference jQuery3_3_1? I'd love it if there were a way to say, "For all the files that live in this directory, jQuery/jquery (there are 2 ways it is called) means jQuery3_3_1/jquery3.3.1".
Or being that it's a Wordpress site, could this be defined in the wp_enqueue_script() call?
Many thanks for your help!
I have a problem with integrating my header and footer in whmcs. Everything works perfectly. Although a strange problem came along. It has something to do with the jquery.js file in my custom layout.
when I comment out the jquery.js in my footer.tpl the dropdown menu in the header does not work on pages where whmcs generates tables. (invoices and domains)
But when I do use that jquery file the tables are still generated fine and the menus work, but then I can't order domains.
No button or text fields appear when ordering a domain.
I know this is not a good and a vague question but this has got me puzzled for quit a while now.
Anyone with who can push me in the right direction to find a solution? Or someone with a similar experience with whmcs integration?
thanks in advance!!
Not sure if you found a solution on this, but likely the culprit is one of two things:
1) The jquery library loading second is clobbering the first one so it no longer exists. To fix this you should call jQuery.noConflict(); prior to loading the second jquery library, this way the $ shortcut gets pushed over to use jQuery and frees up the $ for the new jquery. This however may become a problem if any of the javascript relies on the $ shortcut and must point to the first jQuery library, in which case all shortcuts should be renamed to jQuery.
2) The scripts executing the later jQuery library aren't compatible. This can be problematic if the versions are very different as some methods and capabilities have changed over time.
Best thing to do is always to use only one jQuery library, and use the newest one if possible. Older scripts that rely on the older jQuery should be updated if possible.
SOLUTION: For everyone interested: turned out the solution was moving all files that use DoJo beneath the jQuery UI files, so that jQuery UI is fully loaded before any DoJo stuff loads. Moved them all in the footer in that order (jQuery, then jQuery UI and then alle DoJo related files).
Still wondering though why this has been an issue in WP 4.1, while it worked perfectly without the fix in WP 4.0.
I'm running a Wordpress website which uses both jQuery and DoJo (part of the ArcGIS JS API, loaded from http://js.arcgis.com/3/12/).
After recently upgrading from Wordpress 4.0.1 to 4.1, things broke.
Dojo is returning multiple Error: multipleDefine errors.
Basically it looks like DoJo tries to load a new instance of jQuery, which it shouldn't, since WordPress has loaded jQuery already and there isn't a jQuery module available in the DoJo map. Furthermore, this issues seems to only exists in WordPress, not in a jsfiddle I made including exactly the same scripts.
For debugging purposes I first disabled all WordPress plugins, without any result; the problem kept existing. I went on and found a couple of interesting things. But I'm really stuck in the further debugging proces. I know the scope of this question is rather broad, but any thoughts at all are very much appreciated.
What I know so far/that i'm wondering about:
-Things stopt working after upgrading to WordPress 4.1
-In the info of the multipleDefine error it states https://js.arcgis.com/3.11/jquery.js, which is weird: it shouldn't be looking for jQuery there, since it's already included in Wordpress
-Things break as soon as I included the ArcGIS Javascript API, which includes DoJO
-In addition: leaving WordPress out still gives trouble in this jsfiddle, although dojo isn't looking for jQuery right now http://jsfiddle.net/dhunink/mry5vn3s/8/
<script>
var dojoConfig = {
isDebug: true,
async: false
};
</script>
<script src="http://js.arcgis.com/3.12/"></script>
The things mentioned above leads me to the conclusion that something changed in the last WordPress release that effects my script, although I can't find anything in the release notes that could be linked to my issue.
Any thoughts, suggestions of comments are highly appreciated! Feel free to see all in action at https://tpgrf.nl/testserver/alpha/topotrainer/provincies/.
SOLUTION: For everyone interested: turned out the solution was moving all files that use DoJo beneath the jQuery UI files, so that jQuery UI is fully loaded before any DoJo stuff loads. Moved them all in the footer in that order (jQuery, then jQuery UI and then alle DoJo related files).
Still wondering though why this has been an issue in WP 4.1, while it worked perfectly without the fix in WP 4.0.
When I make changes to CSS and JavaScript files, my users often have to reload a couple of times to get the changes (obviously to clear out the cache).
I was wondering if someone had a really good experience with a plugin to solve this issue.
I am currently using grails 1.3.7 and I use tomcat for my production environment.
Seems to me that this might be the best option for me.
As you say, the cached-resources plugin is a great option.
You need to install it alongside the resources plugin. Assuming the resources plugin is installed and configured correctly, you don't have to do anything with the cached-resources plugin in order to get it to work correctly. Hence the apparent lack of documentation for the cached-resources plugin. Everything you need to know is linked from the resources plugin.
I'm currently linking to jquery from Google. This way I'm not hosting the file on my server.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
Anyone knows of a similar service that's available for the individual jquery plugins?
There isn't one out there yet (though some sparse plugins have their own CDN, like jQuery Tools).
However, the jQuery team is working on this with Media Temple (which currently hosts jquery.com and other related sites)...I'm not sure how far along it is though.