Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8251951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:24:20+00:00 2026-06-08T00:24:20+00:00

I have a page that loads a lot of analytics & data on specific

  • 0

I have a page that loads a lot of analytics & data on specific pages and so far its loading okay but I’m wondering if I can speed it up. The idea I had to try to speed it up was to render each part of the separately.

For example, look at your profile page on SO: it has Questions, Answers, Reputation, Tags, Accounts, Badges, Votes cast, which in my current model would be gathered in the view.py and then rendered by the template. But what if the “Reputation” or “tags” query is slow because of XYZ reason, it will slow down the entire page load even if its not super important for most users. I thought about solving this using JavaScript to make a request and render the json reply on the page asynchronously but I really like Pyramid and using Python, so if possible I would like to use tools I already know than learn javascript to do this. The benefit of this approach is I can load/display the top of the page first and render the rest of the page as the queries complete or order the rending by speed of queries.

Is this possible, or do you have any suggestions on how to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:24:22+00:00Added an answer on June 8, 2026 at 12:24 am

    This surely is possible but the implementation is almost completely has nothing to do with Pyramid or Jinja2. The way Pyramid (or any other web framework) works is that it gets a bit of text from the client (which is abstracted into the request object) and basically returns another blob of text in response, so the operation is more or less atomic – the response is not sent back to the client until the template engine finished generating the full text of the page.

    Actually, there is a way to make Pyramid to send data to the client bit after bit, which will make the browser render the page incrementally (like back at the time of dial-up connections) – which is writing directly into the file-like object which represent response’s body:

    import time
    def some_view(request):
        for i in range(1, 31):
            request.response.body_file.write(".")
            time.sleep(1)
    

    but this approach is a bit limited because you can only append data to what you’ve already sent, there’s no way to, say, display a “please wait, the chart is loading” message and replace it with the real chart, or even to load page header and footer first and then insert something in the middle. Also, this approach would require you to render the template manually or not to use templates at all. I only used this for some long-running batch operations

    As you mentioned in the question, a better technique involves loading bits of the page from separate URLs with JavaScript. I believe the blocks loaded asynchronously are often called “partials”.

    • you register a few separate views which represent your main page and the bits you want to insert, so, say, /questions/123454 would load the main part of the page, /questions/123454/badges would load the block with badges and /questions/123454/related would load the list of related questions

    • you define placeholders in your page where the partials will be inserted:

      < div id=”badges-partial” >Loading…< /div >

    • you add a small bit of javascript to your page to load the partials (well, it will be small if you use jquery 🙂 :

      $(function () {
          $("#badges-partial").load("/questions/123454/badges");
          $("#related-partial").load("/questions/123454/related");
      });
      

    so, as you can see, the JavaScript solution is cleaner, easier and more flexible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that loads other pages via Ajax (think frames, except without
i have a web page that once it loads, it sends a lot of
I have a page that loads content through AJAX. Among this content are some
I have a page that loads a bunch of scripts to prepopulate dropdowns and
I have a page that loads an external HTML page into an iFrame. There
I have a sharepoint page that loads six webparts, each one of them consumes
I have a PHP page that loads external content using other PHP files. I'm
I have a .aspx page that loads three separate .ascx controls to represent adding,
I have an asp page that loads a response user=exists everytime I try to
I have a web application that has a page that loads the content from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.