The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

XHTML v1.0 W3C Validation and the FoxyCart script load

stkstk Member
in General edited June 2015
We installed FoxyCart a while ago and as I do from time-to-time, I validated our page against the W3C Validation Checker, to make certain we are actually serving up proper code for our DOCTYPE (XHTML v1.0 Strict)

As per Foxy Cart install instructions, we added the Javascript code as per recommendation (cut'n paste from "Step 1" instructions from the FoxyCart back-office)

<!-- FOXYCART -->
<script src="//cdn.foxycart.com/OurSite/loader.js" async defer></script>
<!-- /FOXYCART -->
</body>

The W3C validator screeched at us about three things:
  1. There's no type attribute (required for XHTML Strict) ... not a big deal, just add [ type="text/javascript" ] as an attribute to the script tag
  2. Although "defer" is an XHTML attribute, the validator screamed "error", until we changed it to [ defer="defer"] ... again, not a big deal.
  3. The validator wouldn't accept "async" as an attribute, no matter how we specified it. However, after reading this page I wondered if the async is really needed? (so I left it out).
I don't know how many FoxyCart customers are serving up their pages using a XHTML V1.0 Strict DOCTYPE, but for those that are (and want to have valid pages) ... here are the changes to the script tag that allowed us to pass validation (and still achieve 3rd-party script loading in a successful way).

<!-- FOXYCART -->
<script defer="defer" type="text/javascript" src="//cdn.foxycart.com/OurSite/loader.js"></script>
<!-- /FOXYCART -->

Hope this helps.

To FoxyCart Admins ... Maybe a "Using XHTML v1.0 Strict DOCTYPE?" link on the "Sample Code" page, that points customers to this version, might be a good idea. (Alternatively, changing the original to this modified version would likely work for everyone. Might need to test the ramifications of omitting the 'asyc' attribute?)

Cheers,
-stk
Comments
  • brettbrett FoxyCart Team
    Is there any reason you're using XHTML v1.0 strict instead of HTML5?
  • stkstk Member
    edited June 2015
    LOL ... Yep. IMHO it's a lighter, superior DOCTYPE (and sad to see W3C drop dev on it), but mostly, it's b/c it's the published DOCTYPE for the the CMS we're using (tad antiquated).

    Old dogs and all that. :p

    EDIT: I was a lot more active as a developer a few years ago. When I started, HTML5 wasn't even around (think circa 2004). I leapt into XHTML v1.1 when it came out, but later reverted b/c of deficiencies. HTML5 came on the scene and I kind of "gave it a pass" as a "new kid on the block" thing. I see it's grown up since then, but frankly, I don't have the inclination or desire to port a bunch of sites over. XHTML still works well enough for me. Maybe if I get more time to play. (Fairly busy as an elected school trustee, volunteer firefighter and owner of a 5-acre property in B.C.).

    Saw this interesting article comparing HTML5 & XHTML (written 2 years ago).


  • brettbrett FoxyCart Team
    Interesting perspective, and thanks for the info. I started back in 2002ish, and the choices were HTML 4.01 (with the transitional v. strict options) and XHTML 1.0. I went XHTML as well, but I never really considered it a big deal. Minor differences in certain things, but no biggie.

    http://try.powermapper.com/Stats/HtmlVersions shows that HTML5 is the most common, and that's definitely what we're assuming. But I'm glad you were able to modify things to pass the validation, and thanks for sharing!
Sign In or Register to comment.