[Not a bug] /** CDN for jQuery core **/
Wasn't sure where to post this or if it has been addressed :blush:
In v154 jQuery is being called after the load for all site-wide jscript_*.js files located within the custom templates folder.
Was this intentional?
If so, why?
This means all site-wide jscript_*.js files will have to be called from page-specific jscript_*.js or site-wide jscript_*.php files.
zen-cart-v1.5.4-12302014 download
Re: /** CDN for jQuery core **/
So this is weird:
2 - 154 download
1 - uploaded jscript_jquery-1.11.2.min.js
* Works as I think it was intended - removes calls to CDN
2 - uploaded jquery-1.11.2.min.js
* Called it from jscript_php file
* Doesn't load
* Loads jscript_file.js
* Shows jscript_file.js above CDN calls
Re: /** CDN for jQuery core **/
** Disregard **
or even
** Delete Thread **
All works as intended, It was a simple case of misspelling
Nice job on this BTW! :bigups:
Re: /** CDN for jQuery core **/
Quote:
Originally Posted by
rbarbour
All works as intended, It was a simple case of misspelling
Nice job on this BTW! :bigups:
(whew!) At first you had me worried. Glad you got it sorted out!
Re: /** CDN for jQuery core **/
All right, I thought I had this, but now I have a question..
So riddle me this..
What if one has a jQuery plugin that needs to execute on every page (like say to support a navigation menu), is there another mechanism to get this jQuery plugin to be called AFTER jQuery loads, or is hard coding this into the html_header.php file after the jQuery call the best way to achieve this?? (hope this is clear as I am rather loopy tonight and probably need to go to bed soon.. :laugh:)
Re: /** CDN for jQuery core **/
Quote:
Originally Posted by
DivaVocals
So riddle me this..
What if one has a jQuery plugin that needs to execute on every page (like say to support a navigation menu), is there another mechanism to get this jQuery plugin to be called AFTER jQuery loads, or is hard coding this into the html_header.php file after the jQuery call the best way to achieve this?? (hope this is clear as I am rather loopy tonight and probably need to go to bed soon.. :laugh:)
Perhaps you need to define exactly what you mean by 'JQuery plugin'.
Jquery itself is simply a code library. By itself it doesn't do anything.
If by 'JQuery plugin' you are referring to any code (or module) that makes use of the JQuery function calls, then in order for them to work the JQuery library must be loaded before the calls are made (obviously). Since there could be many modules with JQuery function calls it makes sense to load the library *once* upon a page load so that it is available when/where needed.
The 'plugins' themselves should be treated the same as any other Javascript code. IOW, they can be embedded where needed, or automatically loaded on a global or per page basis as required.
Perhaps I'm misunderstand the question?
Cheers
RodG
ps. Although it is possible to load two *different* versions of the JQuery library, this is best avoided where possible as it can cause unpredictable results. (This probably goes withoiy saying though).
Re: /** CDN for jQuery core **/
Quote:
Originally Posted by
RodG
Perhaps you need to define exactly what you mean by 'JQuery plugin'.
Jquery itself is simply a code library. By itself it doesn't do anything.
If by 'JQuery plugin' you are referring to any code (or module) that makes use of the JQuery function calls, then in order for them to work the JQuery library must be loaded before the calls are made (obviously). Since there could be many modules with JQuery function calls it makes sense to load the library *once* upon a page load so that it is available when/where needed.
The 'plugins' themselves should be treated the same as any other Javascript code. IOW, they can be embedded where needed, or automatically loaded on a global or per page basis as required.
Perhaps I'm misunderstand the question?
Cheers
RodG
ps. Although it is possible to load two *different* versions of the JQuery library, this is best avoided where possible as it can cause unpredictable results. (This probably goes withoiy saying though).
You are misunderstanding the question..
jQuery plugin = "'JQuery plugin' you are referring to any code (or module) that makes use of the JQuery function calls"
I know how jQuery plugins work.. (there are a ton of modules here which use jQuery plugins including Zen Colorbox, etc) I know that jQuery must be loaded 1st for my jQuery plugin to work.. However in the new v1.5.4 world, loading a jQuery plugin via the normal upload your jscript_[yourfilenamehere].js file to the jscript folder will mean that the plugin WILL load before jQuery does (see Raymonds initial post here).. I need this plugin to work sitewide. So a page specific javascript file will not work unless I add it to EVERY page folder..
So I want to know if hard coding the link to my jQuery plugin into the html_header.php is the ONLY way to make sure my plugin loads AFTER jQuery (AKA will load sitewide)
Re: /** CDN for jQuery core **/
Crystal,
If using the built in jQuery CDN, I found it very useful to create a jscript_*****.php file, this file loads after the call to the jQuery CDN
In that file is where I call any *****.js files which load after the call to the jQuery CDN
This is also a great way to call page specific *****.js files using PHP
(EXAMPLE)
Code:
<?php if (in_array($current_page_base,explode(",",'advanced_search_result')) or $current_page_base == 'index' and $cPath != '' or $current_page_base == 'index' and $_GET['manufacturers_id'] != '') { ?>
<script type="text/javascript" src="includes/templates/responsive_template_default/jscript/*****.js"></script>
<script type="text/javascript"><!--//
$(function() {
$(document).ready(function() {
YOUR CODE
});
}) (jQuery);
//--></script>
<?php } ?>
The above *****.js file and code only loads on the advanced_search_result page, all index pages where a cPath is passed or index page where a manufacturers_id is passed
or you can just call your *****.js file and code
(EXAMPLE)
Code:
<script type="text/javascript" src="includes/templates/responsive_template_default/jscript/*****.js"></script>
<script type="text/javascript"><!--//
$(function() {
$(document).ready(function() {
YOUR CODE
});
}) (jQuery);
//--></script>
I am still not sure why it was done this way where the built in jQuery CDN call loads after all site-wide jscript_*****.js files located within the custom templates folder but it can be used in a positive way.
You can also embed into html_header.php
just MO
Quote:
Originally Posted by
DivaVocals
You are misunderstanding the question..
jQuery plugin = "'JQuery plugin' you are referring to any code (or module) that makes use of the JQuery function calls"
I know how jQuery plugins work.. (there are a ton of modules here which use jQuery plugins including Zen Colorbox, etc) I know that jQuery must be loaded 1st for my jQuery plugin to work.. However in the new v1.5.4 world, loading a jQuery plugin via the normal upload your jscript_[yourfilenamehere].js file to the jscript folder will mean that the plugin WILL load before jQuery does (see Raymonds initial post here).. I need this plugin to work sitewide. So a page specific javascript file will not work unless I add it to EVERY page folder..
So I want to know if hard coding the link to my jQuery plugin into the html_header.php is the ONLY way to make sure my plugin loads AFTER jQuery (AKA will load sitewide)
Re: /** CDN for jQuery core **/
After further testing and altering, my original post turned out to be correct.
In v154 jQuery is being called AFTER the load for all site-wide jscript_*.js files located within the custom templates folder.
This means all site-wide jscript_*.js files will have to be called from page-specific jscript_*.js
However
In v154 jQuery is being called BEFORE the load for all site-wide jscript_*.php files located within the custom templates folder.
Quote:
Originally Posted by
DrByte
(whew!) At first you had me worried. Glad you got it sorted out!
Re: /** CDN for jQuery core **/
Quote:
Originally Posted by
DivaVocals
I know that jQuery must be loaded 1st for my jQuery plugin to work.. However in the new v1.5.4 world, loading a jQuery plugin via the normal upload your jscript_[yourfilenamehere].js file to the jscript folder will mean that the plugin WILL load before jQuery does (see Raymonds initial post here).. I need this plugin to work sitewide. So a page specific javascript file will not work unless I add it to EVERY page folder..
So I want to know if hard coding the link to my jQuery plugin into the html_header.php is the ONLY way to make sure my plugin loads AFTER jQuery (AKA will load sitewide)
While the jscript_*.js files are loaded before jQuery, the jscript_*.php files are not.
So, this will work:
1. put your jQuery plugin file into the jscript folder, but do NOT add the jscript_ prefix to it.
2. Then create a jscsript_PLUGINNAME.php file in the jscript folder, and in the .php file write only the <script> code. Not even a single line of PHP. Something like:
Code:
<script src="includes/templates/TEMPLATENAME/jscript/THEPLUGINNAME.js"></script>
Re: /** CDN for jQuery core **/
Quote:
Originally Posted by
rbarbour
After further testing and altering, my original post turned out to be correct.
In v154 jQuery is being called AFTER the load for all site-wide jscript_*.js files located within the custom templates folder.
This means all site-wide jscript_*.js files will have to be called from page-specific jscript_*.js
However
In v154 jQuery is being called BEFORE the load for all site-wide jscript_*.php files located within the custom templates folder.
Quote:
Originally Posted by
DrByte
While the jscript_*.js files are loaded before jQuery, the jscript_*.php files are not.
So, this will work:
1. put your jQuery plugin file into the jscript folder, but do NOT add the jscript_ prefix to it.
2. Then create a jscsript_PLUGINNAME.php file in the jscript folder, and in the .php file write only the <script> code. Not even a single line of PHP. Something like:
Code:
<script src="includes/templates/TEMPLATENAME/jscript/THEPLUGINNAME.js"></script>
Awesome thank you both.. My FIRST inclination was to hard code it into the html_header.php file and keep it moving:laugh:, but them I remembered this post, and thought that I should ASK before I DO.. :smile:
I do have another "how should I do this" question DrByte.. I will start a new thread for it when I'm ready.. I need to finish what I'm doing here, and then I shall poke at ya when I post it.. :smile: I am already anticipating that I will get a HUGE groan from you when I pose this question.. But rest assured it is not my intention to give you a headache at all (even if that ends up being the result..:laugh:)