Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 119 posts 447 karma points
    Apr 11, 2016 @ 12:05
    Tom
    0

    Hi,

    Does anyone know of a way to render an umbraco-macro asynchronously?

    Something like this: https://blog.michaelckennedy.net/2012/11/13/improve-perceived-performance-of-asp-net-mvc-websites-with-async-partialviews/

    but with a macro instead?

  • Comment author was deleted

    Apr 11, 2016 @ 13:22

    You could add an alt template that just has the macro on it and then fetch that async...

    So simple steps would be (say that you have a news macro you want to fetch in that way).

    Create a new template (that doesn't inherit from your master site design but is blank), say this new one is called onlyNews

    Drop the news macro on that template

    Using altTemplates you should now be able to render that template on any page by manipulating the query string

    Append ?altTemplate=onlyNews to any page you wish

    So you'll only now need to fetch the result from that in your js

    Does this make sense?

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Apr 11, 2016 @ 13:26
    Dennis Aaen
    0

    Hi Tom,

    If you want to use the AltTemp approach you can see this video from Umbraco TV about the subject.

    https://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/alt-template/

    /Dennis

  • Tom 119 posts 447 karma points
    Apr 12, 2016 @ 09:17
    Tom
    0

    Thanks for the answers!

    I don't think this approach will work in our casse, tough. We render a lot of different macros on every page as the backoffice-users can pick which modules to show on each page.

    Now we have added some heavy, slow loading modules and we need them to be asynchronously loaded or else the website takes forever to load.

    Only other approach I can think of, is an WebApi and loading the data with JS. But that will take a lot of re-writing.

    Any ideas?

Please Sign in or register to post replies

Write your reply to:

Draft