Advice on refactoring a single page site

Coding Critique is the place to post source code for peer review by other members of DevNetwork. Any kind of code can be posted. Code posted does not have to be limited to PHP. All members are invited to contribute constructive criticism with the goal of improving the code. Posted code should include some background information about it and what areas you specifically would like help with.

Popular code excerpts may be moved to "Code Snippets" by the moderators.

Moderator: General Moderators

Post Reply
thinsoldier
Forum Contributor
Posts: 367
Joined: Fri Jul 20, 2007 11:29 am
Contact:

Advice on refactoring a single page site

Post by thinsoldier »

I started with a typical 1 file per page site and added ajaxify: http://www.barznoble.com/ (*warning*: auto-playing music)

Then I redid it as a single page using the history api: http://www.barznoble.com/2/ (no auto-playing music)

What I need is

A: for someone to look through the code of the 2nd version and give advice on how I could improve the way I have the code arranged.

B: suggest an actual front end javascript framework to rebuild it with a 3rd time.
Warning: I have no idea what I'm talking about.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Advice on refactoring a single page site

Post by Christopher »

Other than putting the CSS and Javascript in to separate files, that is too much code to give much advice on.
(#10850)
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Advice on refactoring a single page site

Post by Celauran »

Minify. Separate your concerns, definitely, but minify your CSS and JS. Make sure images are optimized.
thinsoldier
Forum Contributor
Posts: 367
Joined: Fri Jul 20, 2007 11:29 am
Contact:

Re: Advice on refactoring a single page site

Post by thinsoldier »

Christopher wrote:Other than putting the CSS and Javascript in to separate files, that is too much code to give much advice on.
(Referring to /2/ version) For development they are separate but I figured it might be faster to load all the html, css, and js in one shot on the live site.

I'll revert back to individual link and script tags to make it easier to digest and reply again when done.
Warning: I have no idea what I'm talking about.
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Advice on refactoring a single page site

Post by Christopher »

thinsoldier wrote:(Referring to /2/ version) For development they are separate but I figured it might be faster to load all the html, css, and js in one shot on the live site
Instead, think of what the browser will cache. Especially for data driven pages where a parameter or session data will require that the page is sent. Having the CSS and Javascript separate greatly reduces what needs to be sent.
(#10850)
Post Reply