add info to docs: Ajax page navigation pulls in the full document, only uses data-role="page" #5132

Closed
frequent opened this Issue Oct 4, 2012 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

frequent commented Oct 4, 2012

I was wondering for a while, why JQM AJAX requested pages always were considerably large on my application.

Eventually I checked the response and - making perfect sense - JQM does pull in the full page and then discards everything outside <div data-role="page"></div>. In my case my header included a lot of stuff required when loading the app. On subsequent pages I don't need any of it (it's already there), but it gets requested with every page and is promptly dumped when JQM starts enhancing the page.

Maybe add some infos to the docs clarifying this,because it sure saves traffic skipping these parts when building pages requested by AJAX on the server.

Member

jaspermdegroot commented Dec 16, 2012

@frequent

I don't think it's a good idea to skip "these parts" (scripts) on subsequent pages because the page would break when the user refreshes the page.

Contributor

frequent commented Dec 16, 2012

I see. But refreshing will refetch the whole page won't it?

In my case all my page headers look like this server-side (Coldfusion):

    <cfoutput><head></cfoutput>
    <cfif NOT isAjaxRequest()>
        <cfinclude template="../templates/tmp_pageheader.cfm">
    </cfif>
    <cfoutput><title>Page Title</title>
                   </head>
    </cfoutput>
    ....

isAjaxRequest checks if the page was requested by Ajax. If no Ajax, the user refreshed or is starting on this page, so I'm including the whole header. If requested by Ajax, it's JQM, so I'm saving a few k by leaving all the stuff, JQM will disregard anyway.

Seems to work fine. Still, I'm currently looking into offline-ing pages, for which I will probably have to switch to full (static pages) including header.

Member

jaspermdegroot commented Dec 16, 2012

@frequent

Sorry, I misinterpreted "skipping". Thought you meant leaving it out completely.

Contributor

frequent commented Dec 16, 2012

@ugomobi: np.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment