CUTCODEDOWN
Minimalist Semantic Markup

Welcome Guest
Please Login or Register

If you have registered but not recieved your activation e-mail in a reasonable amount of time, or have issues with using the registration form, please use our Contact Form for assistance. Include both your username and the e-mail you tried to register with.

Author Topic: PHP dynamic single footer - automatically creates HTML & CSS validation links  (Read 5200 times)

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • Karma: +171/-1
    • CutCodeDown -- Minimalist Semantic Markup
Oh, and don't worry about stolen content/link mojo, it's all behind a nice robots.txt

https://cutcodedown.com/for_others/robots.txt

I know some folks unnecessarily get their panties in a knot about that.
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

benanamen

  • Full Member
  • ***
  • Posts: 168
  • Karma: +16/-0
Looks like School has started.

So, "knowing" John, he is going to run the page through the validator. Only one thing shows as a problem. What say you?

Code: [Select]
Error: Bad value screen,projection,tv for attribute media on element link: The media projection has been deprecated

From line 11, column 1; to line 15, column 1
To save time, let's just assume I am never wrong.

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • Karma: +171/-1
    • CutCodeDown -- Minimalist Semantic Markup
Only one thing shows as a problem. What say you?
I said it in my explanation, I said it before my explanation in this thread, I've said it at least a half dozen times on these forums already, and I've said it hundreds of times across a half dozen forums.

It is utter and complete BULL for the HTML specification to state which media targets are valid and not valid. It defeats the point of the attribute allowing vendors of new and future products to add them where/as needed and is typical of the flat out ignorance the WhatWG brought to the table with the more idiotic parts of HTML 5. Much less the dozens of different devices -- kiosks, MSN TV, Wii / WiiU / DS -- who's browsers still need it so they don't dick with the layout.

As such with that warning, the W3C Validation can go suck my...

This is PART of why I have no confidence in HTML 5 or in the W3C's ability moving forward to create specifications.

The list of media descriptors in HTML 4 were recommendations, not an exclusive "these only" list. Making it a "you can only use what we say" defeats why the huffing attribute was created in the first damned place!!!

Just more proof that the WhatWG and the folks at the W3C who embraced their HTML 5 idea were utterly and completely unqualified to make 4 Strict's successor.
« Last Edit: 30 Oct 2019, 02:01:12 pm by Jason Knight »
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

John_Betong

  • Full Member
  • ***
  • Posts: 218
  • Karma: +24/-1
    • The Fastest Joke Site On The Web
Hi Jason,

Regret the delay in replying but there is a lot to follow and especially to digest. Many thanks for the detailed write-up and i am honoured to make your "Wall of Fame".

I have taken the liberty to copy your files to my server so comparisons will not rely on server locations.


I also validated and corrected three style.css errors. Your template includes the modified style sheet.

https://supiet2.tk/jason-knight/

Like yourself I do not have a great deal of time to spare and it looks as though I will be starting a new project in the near future.

I have made a start and used the guy in shorts logo and another version modified the script to display SVG rather than as the image contents.

My server is based in London, UK and using https://tools.pingdom.com compared your template to my PHP Framework driven site and found:

https://supiet2.tk/
  My Performance grade: 95
  Page size: 69.7 KB
  Load time: 143 ms
  Requests: 7

https://supiet2.tk/jason-knight/template.php
  Performance grade: 91
  Page size: 69.9 KB
  Load time: 286 ms
  Requests: 8

I hope to implement most of your suggestions and will report back with results  when time allows.
« Last Edit: 12 Nov 2019, 11:12:12 am by John_Betong »
Retired in the City of Angels where the weather suits my clothes

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • Karma: +171/-1
    • CutCodeDown -- Minimalist Semantic Markup
Of those three "errors" in the CSS, two of them are EXACTLY the type of BULLSHIT I'm talking about that renders validation so pointlessly dumbass... The warnings being even worse.

Why? Because it's throwing three errors over one accidental ; where a comma should be. That's why. Again the "derp along screwed up instead of stopping at the ACTUAL error" attitude of the W3C that I'm thoroughly sick of and done with.  It reports a slew of errors on things that are perfectly fine because it's too stupid to point out the ACTUAL error. One typo and it spits the valid code several lines AFTER IT at you as bad? How the hell is that "useful"?

Of course the dipshit warnings about vendor prefixes being just as dumbass as the bitching about "projection,tv". Things needed to support devices that they throw warnings and even errors over because the W3C and WhatWG have gone full Pakled in the latest flavors of HTML 5.

Pingdom is another of those derpy tools that I don't trust since no two runs even come close to each-other in results. Average out of twenty and it's still inconsistent crap... Testing your server with their "tools" from here I'm getting anywhere from 100ms to 500ms for either version. Given the filesizes are nearly the same, off the same hosting, there being a handshaking difference at all (being 8 is under the concurrent connection limit) atwixt them is also total BS.

But setting that aside, you're also testing a single static page. One of the reasons for my approach is to make subpages faster, not just the front page. If you re-use that stylesheet on all your other pages, they will blow your original with the static CSS in the markup out of the water. Why? The external CSS is cached. The external image is cached. Same for moving scripting out of the markup. The moment you serve more than once page sharing these styles and elements, you're in pure /win/ mode.

The only way crapping that stuff into the markup could pay off is if ALL of your traffic is 100% bounce with no return visits.

There's a reason I trust the file sizes and file counts more than I do any "tool" online since they tend to be all over the place on results,  and don't take how caching is being leveraged into account.

If the first-load is... sufficiently fast, speeding up all your other pages on the same site can pay off far larger than most anything else.

NOT that your version of my version is a fair comparison. Why?

Code: [Select]
<style>
  #menu2 {width:88%; margin: 0 auto; text-align:center;}
  #menu2 ul {display:inline-block; text-align:left;}
</style>

I would NEVER, EVER use that tag. That's why. Static style has ZERO business in the markup. 99% of the time you see style="" and 100% of the time you see <style> you're looking at utter and complete GARBAGE HTML.

I'm also curious if how you split it up in the PHP may have impacted its speed. If you're opening and closing <?php willy-nilly, using string addition, so on, and so-forth that could be causing slowdowns.

But I'm a one <?php per file, comma delimited single quote echo kind of developer. The output alone from calling your separate PHP files directly is by itself troubling... particularly when any properly secure system shouldn't even allow me to do so.

That I'm even able to access this file directly:

https://supiet2.tk/jason-knight/menu.php

NOT good.
« Last Edit: 13 Nov 2019, 12:53:15 am by Jason Knight »
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

John_Betong

  • Full Member
  • ***
  • Posts: 218
  • Karma: +24/-1
    • The Fastest Joke Site On The Web
Quote
Of those three "errors" in the CSS, two of them are EXACTLY the type of BULLSHIT I'm talking about that renders validation so pointlessly dumbass... The warnings being even worse.

Why? Because it's throwing three errors over one accidental ; where a comma should be.
This is the offending CSS that caused the w3.org validation errors:

Code: [Select]
text-shadow:
    0.5em 0.25em 0.5em #FFF,
    0.5em -0.25em 0.5em #FFF;
    -0.5em -0.25em 0.5em #FFF,
    -0.5em 0.25em 0.5em #FFF;
  transition:background 0.3s;
}
That script is incorrect as you well should know. Even if there are multiple errors then clearing the first error usually clears other errors because the previous syntax was incorrect and affects following lines.

Say what you like but the validation tool quickly finds incorrect syntax.

Quote
Of course the dipshit warnings about vendor prefixes being just as dumbass as the bitching about "projection,tv". Things needed to support devices that they throw warnings and even errors over because the W3C and WhatWG have gone full Pakled in the latest flavors of HTML 5.
The w3.org validation tool is useful and following their guidelines quickly finds incorrect syntax. Introducing your own syntax means that your complete style sheets requires manually checking and as shown in the first example syntax errors are easily overlooked. Why check manually when dumb computers are available for repetitive tasks?
Quote
Pingdom is another of those derpy tools that I don't trust since no two runs even come close to each-other in results. Average out of twenty and it's still inconsistent crap... Testing your server with their "tools" from here I'm getting anywhere from 100ms to 500ms for either version. Given the filesizes are nearly the same, off the same hosting, there being a handshaking difference at all (being 8 is under the concurrent connection limit) atwixt them is also total BS.

But setting that aside, you're also testing a single static page. One of the reasons for my approach is to make subpages faster, not just the front page. If you re-use that stylesheet on all your other pages, they will blow your original with the static CSS in the markup out of the water. Why? The external CSS is cached. The external image is cached. Same for moving scripting out of the markup. The moment you serve more than once page sharing these styles and elements, you're in pure /win/ mode.

The only way crapping that stuff into the markup could pay off is if ALL of your traffic is 100% bounce with no return visits.

There's a reason I trust the file sizes and file counts more than I do any "tool" online since they tend to be all over the place on results,  and don't take how caching is being leveraged into account.

If the first-load is... sufficiently fast, speeding up all your other pages on the same site can pay off far larger than most anything else.

NOT that your version of my version is a fair comparison. Why?
Code:
<style>
  #menu2 {width:88%; margin: 0 auto; text-align:center;}
  #menu2 ul {display:inline-block; text-align:left;}
</style>
I would NEVER, EVER use that tag. That's why. Static style has ZERO business in the markup. 99% of the time you see style="" and 100% of the time you see <style> you're looking at utter and complete GARBAGE HTML.
You failed to omit that the web page only had four HTML lines and the CSS was added in the header. I forgot to remove the 273 line style.css sheet that did not format the four HTML lines so added two lines  - job complete.
Quote
I'm also curious if how you split it up in the PHP may have impacted its speed. If you're opening and closing <?php willy-nilly, using string addition, so on, and so-forth that could be causing slowdowns.
The PHP Framework rendered page is faster than the single html page and there are no slowdowns?
Quote
But I'm a one <?php per file, comma delimited single quote echo kind of developer. The output alone from calling your separate PHP files directly is by itself troubling... particularly when any properly secure system shouldn't even allow me to do so.
 That I'm even able to access this file directly:
https://supiet2.tk/jason-knight/menu.php
NOT good.
That is the file with that required two CSS lines in the header.

Perhaps not good but at least it does not time out :)

Edited by Jason Knight, reason: Swapped script tags for code, this forum doesn't have script bbCode
« Last Edit: 13 Nov 2019, 02:18:36 pm by Jason Knight »
Retired in the City of Angels where the weather suits my clothes

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • Karma: +171/-1
    • CutCodeDown -- Minimalist Semantic Markup
That script is incorrect as you well should know.

Yes, as I said, semi-colon where there should be a comma. Where for many that minor typo is effectively invisible hence:

Even if there are multiple errors then clearing the first error usually clears other errors because the previous syntax was incorrect and affects following lines.

Except the first error they list is three lines later! Hence you're not looking anywhere NEAR where the actual error is! It took me multiple passes and several minutes to find that semi-colon even with the validation report because the first of three errors was significantly AFTER the actual error location! As such you're not quickly finding a damned thing. When the first error reported is the derpy validator claiming that :background is an invalid psuedo-state (when it's a huffing property that's completely valid) that ceases to be a useful debugging tool.

Laugh being if I had run my normal checks -- via Edge's document inspector that also reports CSS errors -- it would have been caught in a meaningful manner by reporting the ACTUAL invalid semi-colon. I'm worried that blink based Edge is going to lose that feature.


Introducing your own syntax
You've said this a few times and I have to say, WHAT introducing my own syntax? This is just me disagreeing with things they added in HTML 5, and REALLY disagreeing with things they removed in HTML 5.

See the derpy switch of TFOOT and TBODY order, the removal of projection,tv from the spec, reporting errors for once VALID vendor created media targets (the entire POINT of the media attribute) because they now have some dumbass magical list you have to match.

The media targets of the media attribute should be none of the HTML specification's bloody business, and under 4 Strict that's exactly how they worked. It's the job of UA makers to determine what values to support and how... JUST like there should be NO default appearance for HTML elements in the HTML specification, because that's not what HTML is for or why it was even created in the first place!

If it were 4 strict both projection and tv were valid, as were ANY other values because it was up to vendors not the specification to create them so as to best handle any conceivable devices past, present, or future. Their changing that is one of the MANY things in HTML 5 that makes it total 100% herpafreakingderp.

Hence my zero confidence in the WhatWG or W3C in terms of the direction they're dragging HTML... right back to the ugliest and worst of 1990's browser wars era practices.

The PHP Framework rendered page is faster than the single html page and there are no slowdowns?
Sorry but bullcookies. Over ten runs the two versions off your server (both of which seem to be PHP) trade blows +/- 300ms here, though the average of 350ms for the original page and 240ms for the one in the subdirectory tends to put that to the lie.

But again those are pingdom's numbers and they provide anything BUT consistency in testing... never have with anywhere form 200ms to a full on second of difference across runs not being at all unusual.

How many runs did you make? What were the best, what were the worst, what was the average. If you only ran the test once, it probably doesn't count.

Perhaps not good but at least it does not time out
I think you completely missed my meaning. Accessing it directly via it's URI

1) should be blocked. It should 404. I should NOT even be able to access that file.

Take for example:

https://cutcodedown.com/template/common.template.php

The file is there. You're NOT allowed access to it via http/https. That's a good thing. (something I need to fix with this SMF install in fact...)

2) if I AM able to access it, as an include it should output NOTHING since that can become a security risk depending on what's in the include. In this particular case there are no nasties, but it's bad practice to make includes that are raw code. Particularly those that form the document <head>... hence the content of such an include should be wrapped in functions.

But again, <?php only once, no ?>, and any/all output wrapped in echo...

Though to be fair, I'm the nutter who thinks that heredoc, nowdoc, php shorttags, and double quoted strings should be stricken from PHP entirely. Just as includes should block direct output and instantly break local scope.

Hence my using this little bit of derpitude all the time:

Code: [Select]
function safeInclude($filename) { include($filename); }
JUST to break the scope where an include occurs so no locals are passed... but then I isolate scope -- PARTICULARLY of the database connection -- in ways most people never even think of.
« Last Edit: 13 Nov 2019, 03:41:06 pm by Jason Knight »
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 919
  • Karma: +171/-1
    • CutCodeDown -- Minimalist Semantic Markup
I just took a moment to look at pingdom's output because that grade ranking was bugging me... as there's no reason for it to drop any points, if anything it should rank better...

Turns out they rank identical except for one thing... the "use expires heading" claim. Because mine has one extra file, your server not setting expires headings (a pointless bit of placebo bullshit) it dings it down from 45 on yours to 37 on mine. That's what's skewing the ranking.

A bullshit value in most cases since all these companies act like they're something horrifically wrong with the browser default expiration times, when in most cases browsers know better than site developers what the needs for caching are client-side.

Google PageSpeed pulls the same asshat stunt.

If we removed that from the ranking? It becomes 98.2 for mine, and 97.33 for yours. Yours taking the extra ding for using cookies, something these automated systems put far too much weight into.
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

 

SMF spam blocked by CleanTalk

Advertisement