Forums / Bug Reports / template_default jQuery loader does not validate at http://validator.w3.org

template_default jQuery loader does not validate at http://validator.w3.org

Locked

Views: 10,385

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
5 Jan 2015, 5:41 PM
#1
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

template_default jQuery loader does not validate at http://validator.w3.org

I am not sure this is officially a "bug report" or not, but posting it here for lack of a better place to do it

Vanilla install of 1.5.4 gives me 11 errors and 5 warnings as posted by Melanie Prough in another thread. Validation report is here:

HOWEVER, if I use CSS JS loader on my install, i get a clean validation with no errors.

My problem is that I am worried that the code in includes/templates/template_default/common/html_header.php which is causing all the validation errors - specifically:

/** CDN for jQuery core **/
?>
  <script>window.jQuery || document.write('<script src="//code.jquery.com/jquery-1.11.1.min.js"><\/script>');</script>
  <script>window.jQuery || document.write('<script src="<?php echo $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript'); ?>/jquery.min.js"><\/script>');</script>

is not being called when using css js loader and that this has something to do with PCI compliance and is necessary code.

If I move the 1.5.4 core includes/templates/template_default/jscript folder into the classic directory, I get one error
as can be seen here

Can you help? I have a new site for a client scheduled today and I do not want to do it in 1.5.4 if there are going to be validation errors, or if my installing the css js loader is going to break PCI compliance if that is what these scripts are being used for.

Thanks to anyone who can help!

6 Jan 2015, 1:04 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: template_default jQuery loader does not validate at http://validator.w3.org

The <script> syntax is perfectly valid for HTML5.
(and yes, I understand that ZC v1.5.4 ships with an XHTML template).

So ... if you're not putting an HTML5 template onto your site and you need it to pass XHTML validation in the W3C validator,
then there are 2 sets of changes to make:

  1. /includes/templates/template_default/jscript/jscript_framework.php, line 9:
<script type="text/javascript">

and line 15:

  options.url = options.url.replace("&", unescape("&"));

and line 67:

        if (jqXHR.status === 200 * contentType.toLowerCase().indexOf("text/html") >= 0) {
  1. /includes/templates/template_default/common/html_header.php, around line 106 change this:
/** CDN for jQuery core **/
?>
  <script>window.jQuery || document.write('<script src="//code.jquery.com/jquery-1.11.1.min.js"><\/script>');</script>
  <script>window.jQuery || document.write('<script src="<?php echo $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript'); ?>/jquery.min.js"><\/script>');</script>

to this:

/** CDN for jQuery core **/
?>
<script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript type="text/javascript" src="//code.jquery.com/jquery-1.11.1.min.js"%3E%3C/script%3E'));</script>
<script type="text/javascript">window.jQuery || document.write(unescape('%3Cscript type="text/javascript" src="<?php echo $template->get_template_dir('.js',DIR_WS_TEMPLATE, $current_page_base,'jscript'); ?>/jquery.min.js"%3E%3C/script%3E'));</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.

6 Jan 2015, 1:09 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: template_default jQuery loader does not validate at http://validator.w3.org

(Unfortunately, the way the W3C validator assesses things (and ostensibly also the XHTML spec), it's not just a simple matter of adding type="text/javascript" to the <script> tags. Hence the reworked post above, and removal of prior discussion.)

.
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.

6 Jan 2015, 3:25 PM
#4
stellarweb avatar

stellarweb

Zen Follower

Join Date:
May 2006
Location:
Montana
Posts:
293
Plugin Contributions:
8

Re: template_default jQuery loader does not validate at http://validator.w3.org

Got it THANKS TONS!! This helps me TREMENDOUSLY with upgrading sites that do not have html5 templates! I was also able to incorporate the js code into css js loader's html_header.php file.

6 Jan 2015, 4:12 PM
#5
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: template_default jQuery loader does not validate at http://validator.w3.org

stellarweb:

Got it THANKS TONS!! This helps me TREMENDOUSLY with upgrading sites that do not have html5 templates! I was also able to incorporate the js code into css js loader's html_header.php file.

If you are using the css js loader, then you do not need to put those line in the html_header.php file. You can set the jquery files through the autoloader files

6 Jan 2015, 4:39 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: template_default jQuery loader does not validate at http://validator.w3.org

css js loaderI've always had bad experiences using the css/js loader addons. Total chaos and impossible upgradability.

.
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.

6 Jan 2015, 5:05 PM
#7
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: template_default jQuery loader does not validate at http://validator.w3.org

DrByte:

I've always had bad experiences using the css/js loader addons. Total chaos and impossible upgradability.

That's debatable :) I know most people do not like it, but I have always been a fan of it. Once you get used to it, it is easy to work with, and I find it to have better control over what files you want to load and when.