These two bytes may not matter to you...

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #120, on September 30th, 2011, 08:11 PM »
phpseclib... What does it do?

How would you trim the comments? Through a commandline tool? Some script? Or manually...? I've done some extra comment ripping but it's dull and frankly on the next getid3 update I probably won't bother at all. Oh man, how do I *hate* dirty source code with plenty of commented out functions, things like that... It's definitely not something I'd release, personally. And these pieces of code have been in there for years...!

Okay, a small one now. Does anyone remember any situation where Wedge/SMF might put a slash (/) inside the query string, i.e. after the "?" part of the URL? Any variable values that can contain a slash? I can't think of anything, but if I could be sure that it doesn't happen, I could safely remove a substr and a strpos from the main codepath.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: These two bytes may not matter to you...
« Reply #121, on September 30th, 2011, 08:16 PM »
phpseclib is the SSH/SFTP library in pure PHP. I figure if I can get it small enough, I can justify including it into the plugin manager for handling permissions changes on hosts where FTP isn't an option. It's 600KB to kick off, I was down to about 400KB without having to trim too many of the comments by general cleanup, and if I strip all the comments, I can get it down to probably 250KB.

I don't really envisage having to update it very often, which is advantageous if it's bundled, and I can fully sympatheise with your issues with getID3.

The old package manager could put slahses into the URL when browsing a package server. The language editor shouldn't but you never know, and I'm not sure about the skin selector. It isn't common, though, not at all - it's sufficiently rare that you could remove it and we'll fix anything that gets broken in consequence.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #122, on September 30th, 2011, 08:39 PM »
- Oh yeah, I forgot about that one, sorry...

- Well it's in the admin area only then, I guess... Nah, the skin selector base64-encodes all URLs it has in the query string :)
I suppose I could remove that, then, yeah... When you're back, have a look at the index.template.php change in rev 1043. The extra code is after the $qmark test. It's probably not worth removing, though... I mean, one extra substr... it's fast enough.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: These two bytes may not matter to you...
« Reply #123, on September 30th, 2011, 08:48 PM »
Well, it is a per-page test after all, but since the test is to grab position then look for === false, I'd say it's probably as fast as it's going to get and that it's far from the biggest of the consumers...

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #125, on October 1st, 2011, 03:52 PM »
Was using the main menu in Chrome and... What?! It's glitchy!
I never noticed that until now. Pete, do you remember if this has always been that way, or is it a recent thing?
When hovering a top level item, its menu opens with both a vertical animation, and a fade-in effect. Problem is, once the fade-in is finished, the anti-aliasing value for the text is changed to make it anti-aliased, meaning it's aliased during the animation. This is probably a jQuery problem but... in Chrome, FFS?!
Posted: October 1st, 2011, 03:46 PM

Okay, narrowed it down to -webkit-border-radius... If it's set (to anything), the text inside gets aliased. Uh!

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #127, on October 1st, 2011, 04:24 PM »
Reported bug to the Chrome team... (reproduced on the demo site.)

And it's not jQuery, as it can be triggered by changing the border-radius value on the fly.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #129, on October 1st, 2011, 04:51 PM »
Oh oh, don't get me started on hasLayout... :P
Last week I was actually trying to *remove* hasLayout from an item. Which turns out to be pretty much impossible! :(

Another, in Class-DB.php:

      // A database error is often the sign of a database in need of upgrade. Check forum versions, and if not identical suggest an upgrade... (not for SVN versions!)
      if (allowedTo('admin_forum') && defined('WEDGE_VERSION') && WEDGE_VERSION != @$modSettings['weVersion'] && strpos(WEDGE_VERSION, 'SVN') === false)
         $context['error_message'] .= '<br><br>' . sprintf($txt['database_error_versions'], WEDGE_VERSION, $modSettings['weVersion']);

$modSettings['weVersion'] isn't defined anywhere by Wedge. It may be some variable we used to set but removed eventually... Since I believe you recently discussed this particular error message, do you remember anything about it?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: These two bytes may not matter to you...
« Reply #130, on October 1st, 2011, 05:01 PM »
Think you'll find it's in the installer, as the first entry into the wedge_settings table. It certainly was there last time I did a fresh install.

It's really not worth keeping, because it's somewhere between misleading and useless, and frankly unless it's going to be updated by installers/upgraders (which SMF doesn't!) it is only useful for checking fresh install. Since I was doing tech support without even checking that before (since I made sure to keep a note of what versions did what changes) it certainly didn't help me, and I don't think it's helped anyone else much.

I haven't discussed this one recently, though.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #131, on October 1st, 2011, 06:11 PM »
Quote from Arantor on October 1st, 2011, 05:01 PM
Think you'll find it's in the installer, as the first entry into the wedge_settings table. It certainly was there last time I did a fresh install.
Sorry -- I didn't find it there but then I realized my current search session was on *.php, not *.*... Oops. As a result, I missed many 'addon' occurrences. Fixed in rev 1046. Hopefully I didn't break anything else.
Quote
It's really not worth keeping, because it's somewhere between misleading and useless, and frankly unless it's going to be updated by installers/upgraders (which SMF doesn't!) it is only useful for checking fresh install. Since I was doing tech support without even checking that before (since I made sure to keep a note of what versions did what changes) it certainly didn't help me, and I don't think it's helped anyone else much.
Then feel free to remove it :)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: These two bytes may not matter to you...
« Reply #132, on October 4th, 2011, 12:04 PM »
In other news, I thought I'd try a new tactic with getting phpseclib down in size. I'm not yet sure whether I'm entirely happy with it, but anyway.

I went through the files, making sure I only had the files I needed, then pushed them all through http://customhost.com.ua/php-minify/ to strip comments. I made sure to leave whitespace in and preserve newlines since I still want readable source, then did some regex magic to convert all the leading 4-spaces to tabs and I'm now down to ~280K with it. My target's always been 250KB to try and slim it down to, since if it's there, I figure it's small enough to justify its inclusion.

On reflection, I realised that I was a bit uptight with my PHP 5.3 compatibility changes, a class having its own name as a function will still be called for a default constructor, provided it's not namespaced, so I don't need to go through and convert the default constructors to __construct, but I now don't have the source I did changes to initially, it still has all the PHP 4 compatibility in it, and more irritatingly I ditched the conversion I did to indicate visibility of variables - they're all declared as var rather than public/private, which means they'll all be technically public.

Here's the thing: do I do it *right* and fix all that, or do I leave it, knowing that it'll work because it's not actually an issue per se and leave it being smaller?
Re: These two bytes may not matter to you...
« Reply #133, on October 4th, 2011, 12:45 PM »
Oh, I'm slacking today. Instead of a bunch of var declarations (or a bunch of private declarations, or whatever), I can do simply one big one and make it a long line. Means I get to do it properly *and* save space compared to how it was before!

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: These two bytes may not matter to you...
« Reply #134, on October 4th, 2011, 04:35 PM »
Well... Readability is important -- when you're planning to maintain the thing!
But do you think you're going to?

I was looking for similar software, thanks for pointing to it. I manually passed all of the getid3 files to it, stripping comments and whitespace (but not doc comments because getid3 uses this in its parser... Geeky for sure, but a horrible way of doing things!), and keeping just the header comment.
Normal version: 702kb, zips to 133kb
Minified version: 522kb, zips to 98kb

Not bad...! Although I'll have to test it, I guess... It's an interesting alternative, and it only took 15 minutes or so to convert all of the files. Something I *can* do on each major release for sure...

Okay, speaking about minification. I've been thinking about many things...

- doing on-the-fly minification (i.e. not cached...) on inline JS and CSS. Do you think it's realistic? I'm not sure myself, but I could cook up a simplified minification function, although I wouldn't know how to deal with strings. Hmm. Still, just as an example, if I manually minify the noi_resize() code, I save something like 60 to 80 bytes off the page, and a reasonable ~20 bytes when gzipped. Considered it's to be found on every single page...

- media cache: I'm always tempted to add a htaccess for the media folder, just so I don't get the pagespeed warning when it can't find a far-future expiration date. Problem is -- if you replace the files with a newer version, if the files have the same name, then the generated name has the same name as well. And that's only for thumbnails... Previews and full pics are accessed through PHP, so I can't "regenerate" a new filename for them, it won't help at all.
Need I worry about caching media items at all...?

- considering using YepNope to load jQuery and subsequent code. YepNope is 1.6kb minified and gzipped, so it's not exactly super-light, but at least it would trick pagespeed into thinking no other JS is executed at page load time, so I'd be likelier to get it to a perfect score... Main problem is, I doubt I'll be saving any time here. The only 'big' script we have to load is jQuery, the rest is negligible (except maybe for script+theme). At best, jQuery will load in parallel while YN is loading other JS files, and thus will be able to execute everything at the same time instead of waiting to load script+theme and other scripts after jQ is loaded. Still, if jQ is integrated into the main local file, it's even more pointless. At worst, YN wastes time executing itself when both jQ and local scripts are already cached... :-/

- Considering using "FileETag none" in all htaccess files. I'm not a specialist though... But as soon as we have an expiration date, ETags aren't useful at all. I'm not sure if it should be done for all files.

- IP packets carry the cookie, as everyone knows. My question would be, does it carry it only in the first packet of the page, or on every single freakin' packet? In which case it'd be in our interest to make cookie size as small as possible...

- I noticed that by default, avatars are loaded into the attachment folder. I *know* AeMe will change the entire system, but since I still don't know when I'll deal with this, I'd like us to consider creating a 'custom' folder in /avatars/ and upload all avatars there by default -- and obviously, set Wedge by default to show clear URLs for these avatar images. We save *by default* as many HTTP requests (to PHP FFS!) as there are avatars on the page.