PDA

View Full Version : A great PHP + Javascript example


Dylan Leblanc
11-26-2002, 07:42 AM
Have a look at this page and view the source:
http://www.skyscraperpage.com/diagrams/?d=


Most of the page is output by Javascript. Since there is a large amount of data displayed in a repetitive manor, I decided to pack all the data into a Javascript array, and then have it output by a function in an external Javascript file.

This has reduced the page sizes from about 60k to less then 13k.


I grab all the data out of the database, and then have PHP format it into proper Javascript array syntax. Very quick and easy.

ConfusedOfLife
11-26-2002, 12:18 PM
Your page is way coooooooooooooooooooool!!

duniyadnd
11-26-2002, 04:59 PM
pretty cool site, and cool scripts, def. in my bookmarks.

curious, when you say it was previously 30kb, do you mean you spit out all your code using php from I presume your sql database?

Thanks
Duniyadnd

Dylan Leblanc
11-27-2002, 08:29 AM
The 30 k pages were done in all HTML with no Javascript. So there was a lot of excessive TABLE, TR and TD tags to format the large table. Before I started using CSS the pages were over 100 k.

Here is the older HTML output:
http://skyscraperpage.com/diagramsold/display.php

ConfusedOfLife
11-27-2002, 08:37 AM
If I'm right you pulled out the information you needed from the database and instead of writing them all to the page by PHP, you just populated your relevant arrays in JS and let it make the page, right?

Dylan Leblanc
11-27-2002, 08:42 AM
Yup. The JS file that outputs the page is here:
http://skyscraperpage.com/diagrams/matrix.js