Loading...

Top
PFQ Banner

This is PokéFarm Q, a free online Pokémon collectables game.

Already a user? New to PFQ?

A bit of info on the Header updates

Forum Index > Core > Announcements > News Archive >

Pages: 1234

Niet [Adam]'s AvatarNiet [Adam]
Niet [Adam]'s Avatar
Hey guys! This post may be quite technical and/or difficult to follow, but for those who are interested: this is what I did with the header are (toolbox, navbar, announcement box) Basically, I realised that that part of the page has to load every single time you load a page. That might seem obvious, but it means a lot. In fact, the header area was about 9Kb in size! Again... doesn't seem like much, but think about it. 9Kb. Per page load. Across all users. Let's say... 2,500 users come online in a day. On average, they might load a hundred pages. That's 250,000 times 9Kb, or over 2GB, the size of a small USB drive. And that's not counting Guest users! They do get a smaller Header area though... so let's estimate that at about a total of 4Gb. PER DAY. That's a lot, just for the header! I decided this was unacceptable. Now, when you actually load the page, it is initially loaded with something like this:
<div id="toolbox"><code>in=;time=1392838893;on=[246,101];not=[0,0];out="yQtJSl";me=["Niet",10,1,"Niet's Mountain Cave"];money=[54332,2895,325]</code></div>
Yes, it looks ugly. That's the point XD Packing information into a small space makes it ugly. Have you ever tried to open a ZIP file in Notepad? See how ugly it is? This is comparatively tame! But anyway, you don't get to see that, because... well, you see a very nice header with a link to your user page, Farm, users online, etc. That's thanks to the JavaScript. When the page loads, pretty much the first thing the JavaScript does is look for that code, and process it, converting it into the actual result. You may realise, of course, that this means I had to add more JavaScript to the site. Yes I did. In fact, I had to write about 9Kb of JavaScript. Hang on a sec... If I was trying to make something that was 9Kb smaller, and I wrote 9Kb of code to do it... didn't I make it bigger? Well, yes and no. Yes, I made it bigger, but there are a couple of important points: - JavaScript can be compressed (minified). The code I write is all tidily organised, but before it goes on the site it gets mercilessly crushed to be as small as possible. In this case, the site's main JavaScript file gets crushed by about 30%, which is great! Makes my 9Kb of additions closer to 6Kb instead. - JavaScript files are cached. This means they are loaded once, and then your browser doesn't care any more. It knows the file won't change because the server tells it so (and I did some very clever cache-busting stuff for when the file does change). All in all, this means that the extra JS contributes a total of 6Kb per user, ever (or at least, per update of the code). For our 2,500 users, that adds up to 15Mb of bandwidth. And remember, that's not per day any more. Your browser will cache the file forever, no matter how many pages you load. Going from 4GB to 30Mb (factoring in guest users) is massive. You can see right there, it's two orders of magnitude different! A 99% savings on bandwidth for that element of the site! Also you get a quick visual indication of when there's a new Announcement, which is awesome, but only if you're paying attention :p
Clip from Pokémon anime, re-lined by me
-- OMNOMNOM!
Featured story: Injustice Feedback welcome!
Peregrin123's AvatarPeregrin123
Peregrin123's Avatar
Could ya say that in english
Avatar created by Stormfang
Click Mo to link to Storms's Shop of Spritey Stuff
Join the counting game
Niet [Adam]'s AvatarNiet [Adam]
Niet [Adam]'s Avatar
I'll try! Basically, I spent a lot of time and effort making it so your browser has to download less stuff when you use the site. This is good for you - especially if you're on a slow connection - but also good for PFQ in general because it has to do less work. And not to toot my own horn, but this kind of thing is why PFQ is so much better than other sites - as a developer I will go out of my way to practically torture myself in order to get the site as optimal as I can make it. Most developers won't do that, because they can't be bothered.
Peregrin123's AvatarPeregrin123
Peregrin123's Avatar
It is better than most websites I have to agree on that one
RisingWolfe's AvatarRisingWolfe
RisingWolfe's Avatar
That's awesome how you can do that! ^^ And how you will :3 YOur so awesome Niet! ^^
Profile Pic from: Doduo Call me Wolfe! I have 2 comics that me and a friend post every week/month! Tears and Sorrow Magic Bound Click my first and second Melan! Both named after Dragon Ball Z characters!
Meu's AvatarMeu
Meu's Avatar
Looks awesome. The little menu for useful links is also great- it's a lot cleaner now.
shop + journal + credit
if my journal is deleted: Art Credit: Avatar & About Me: Zan Forum Signature: Silver
phone lines follow us, like heartbeats in the dusk hold my hand and gush, sweet landscapes from the bus
263
Thank you so much for making the site more efficient, Niet! I know Sally appreciates it too, and I appreciate the Portal reference. You made my day that much better. :)
DementedTink's AvatarDementedTink
DementedTink's Avatar
looks great and good job, love this place and it gets better each day/update. keep up the great work
They call me Tink my 1st avatar pic is a free to use
Crazy's AvatarCrazy
Crazy's Avatar
I like it :) (I don't know if doing this makes the pages load faster but it seems to xD. )
Avatar made circe ^^ Help with some research?
ShinySylveon's AvatarShinySylveon
ShinySylveon's Avatar
This is really good considering the server lags sometimes through pages, and I hope these reduce or disappear altogether.
~Shiny umbreons are the best.

Pages: 1234

Cannot post: Please log in to post

© PokéFarm 2009-2024 (Full details)Contact | Rules | Privacy | Reviews 4.6★Get shortlink for this page