Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    bug [Not a bug] /** CDN for jQuery core **/

    Wasn't sure where to post this or if it has been addressed

    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
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  2. #2
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default 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
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  3. #3
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default 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!
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: /** CDN for jQuery core **/

    Quote Originally Posted by rbarbour View Post
    All works as intended, It was a simple case of misspelling

    Nice job on this BTW!
    (whew!) At first you had me worried. Glad you got it sorted out!
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default 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.. )
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  6. #6
    Join Date
    Jan 2007
    Location
    Australia
    Posts
    6,167
    Plugin Contributions
    7

    Default Re: /** CDN for jQuery core **/

    Quote Originally Posted by DivaVocals View Post
    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.. )
    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).

  7. #7
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: /** CDN for jQuery core **/

    Quote Originally Posted by RodG View Post
    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)
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

  8. #8
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default 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 View Post
    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)
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  9. #9
    Join Date
    Feb 2010
    Location
    Syracuse, NY
    Posts
    2,159
    Plugin Contributions
    17

    Default 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 View Post
    (whew!) At first you had me worried. Glad you got it sorted out!
    Website - Github. Like the ZCA Bootstrap 4 Template? Donations Welcome. Bootstrap Plugins?

  10. #10
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: /** CDN for jQuery core **/

    Quote Originally Posted by DivaVocals View Post
    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>
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. [Not a ZC core bug] Swedish Weekday in product_info
    By FrilansReklam in forum Bug Reports
    Replies: 2
    Last Post: 27 Feb 2013, 07:39 PM
  2. v150 [Not a ZC core bug] ckeditor.php addon calls insecure site
    By The Other Air Force in forum Bug Reports
    Replies: 0
    Last Post: 22 Mar 2012, 03:53 AM
  3. Replies: 4
    Last Post: 24 Jul 2010, 01:06 PM
  4. Replies: 2
    Last Post: 19 Nov 2009, 07:48 AM
  5. Replies: 1
    Last Post: 1 Sep 2009, 06:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR