123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|722|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> Making XML Smaller

Fri, 05 Aug 2016, 03:09
Jayenkai
Reminder : ’’Because it's XML’’ is NOT the reason your xml output is so alarmingly large. Check for redundancy and repetition. I just got a 97kb xml file down to 17kb!

-=-=-
''Load, Next List!''
Fri, 05 Aug 2016, 03:09
cyangames
Also, gzip
Fri, 05 Aug 2016, 03:13
Jayenkai
Not sure I can gzip from Blitz3D!!
Fri, 05 Aug 2016, 08:35
cyangames
Haha! Probably not
---
Reminds me I need to give Monkey another go again sometime soon!

-=-=-
Web / Game Dev, occasionally finishes off coding games also!
Fri, 05 Aug 2016, 14:33
therevillsgames
I just got a 97kb xml file down to 17kb!

Magic! How?
Fri, 05 Aug 2016, 14:50
Jayenkai
It's from my Music Archive.

It used to hold the album name with each track, along with mp3 links.


So, a fair bit of redundancy.
Instead, I switched the primary field to be the Album, then added tracks into each Album.
Which, realistically, is how I bloody well should've done it in the first place.

I also managed to strip out the Filename and LoFi parameters by sifting through the music archive and ensuring the filenames are identical to the track titles, but with .mp3 or _lofistream.mp3 added on. This wasn't always the case, hence the need for the fields. But now everything has websafe titles, it's simply a case of converting the title to a url in the javascript, rather than having to specify it each time.

So, rather than the above mess, it's now more like..


..which is infinitely shorter!

So, remember kids, if your XML is spiralling out of control, strip it back, rethink the order, and consider removing the repetition. It sometimes helps trim it all down.

-=-=-
''Load, Next List!''
Fri, 05 Aug 2016, 19:41
Stealth
But but. Why XML when you can JSON?

Get that packet down to 10kb.

-=-=-
Quit posting and try Google.
Sat, 06 Aug 2016, 01:14
Jayenkai
Xml's fine, as long as you use it wisely and not as lazily as I had previously

-=-=-
''Load, Next List!''
Sun, 07 Aug 2016, 16:28
therevillsgames
Yeah, thats a nice change to your XML file... I would have put the albumtitle as an attruibute to the album tag:


I remember talking to a team leader on changing our XML to JSON to reduce the size of the packets sent to a mobile client... he suggested to change the XML from readable tags to single character tags! OMG! LOL!
Sun, 07 Aug 2016, 21:52
Jayenkai
Then I definitely won't admit to having already considered doing just that!!! (The single character thing)

As for putting the data into the brackets, hadn't even thought of doing that!!
Tsk!!

But, no, it's a small enough size, now. That'll do as it is.

-=-=-
''Load, Next List!''
Mon, 08 Aug 2016, 01:15
therevillsgames
LOL @ single characters

By having attributes you would simplify your parsing too.

You could rename "track" to "song", saves 1 character per track
Mon, 08 Aug 2016, 08:47
rockford
Single char variables went out with the ZX Spectrum, didn;t they?
Mon, 08 Aug 2016, 10:51
Jayenkai
N!
Mon, 08 Aug 2016, 18:46
Stealth
I stand by my statement about JSON.

I ain't no noob guys Look at that profile pic. Lil Steve Jobs over there

I know J tho, he #DGAF

XML = 619 bytes
JSON = 446 bytes

Fxck those 200 bytes.

Proof of work: https://www.freeformatter.com/xml-to-json-converter.html

-=-=-
Quit posting and try Google.
Tue, 09 Aug 2016, 00:52
Jayenkai
14k's small enough for me. You only load the xml once, when you first load the page. The javascript takes care of everything else.

https://agameaweek.com/Music?Precarious-=-Polygon

Works perfectly fine!

What I could REALLY do with doing, is getting the "Next Track" stuff to work on iOS.
I'm not sure that's do-able. It seems to stop working once the device goes to sleep.
HTML5 can do many things, but forcing an iPhing to play tunes in the background, doesn't seem to be one of them..

-=-=-
''Load, Next List!''
Tue, 09 Aug 2016, 16:51
Stealth
Lol yes. It's not 2005. Internet is good these days

Doesn't iPhone support background tasks? I think audio streaming is one of them (used by Pandora and YouTube).

-=-=-
Quit posting and try Google.
Tue, 09 Aug 2016, 22:56
Jayenkai
If you start a track, close the iPhing, then yes, it'll continue in the background.
Unfortunately, once the track's ended, that's where the issue hits.
The browser has a "Not unless you're active on the page" rule for starting html5 audio. Essentially, they've made it so that a rogue webpage can't start playing adverts when your phone isn't even switched on.

So, although it will continue to play a previously started track, it won't then move on to the next track, unless the browser is at the forefront, and the currently active app.

It's obviously been done for good reason, but it's a pain in the arse!!

-=-=-
''Load, Next List!''