No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    q-img preloading

    Framework
    4
    6
    1024
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      walfin last edited by

      Hi, is there a way to preload all q-imgs on a page (even if they’re not displayed)?

      dobbel 1 Reply Last reply Reply Quote 0
      • dobbel
        dobbel @walfin last edited by dobbel

        @walfin

        how do you preload an image when it is displayed?

        W 1 Reply Last reply Reply Quote 0
        • W
          walfin @dobbel last edited by

          @dobbel My problem is that the q-imgs lag the screen (on phone) when they first appear (I’m using a lot of colourful icons in svg format).

          I want to force-preload all q-imgs so they start loading immediately when the app starts.

          1 Reply Last reply Reply Quote 0
          • Hawkeye64
            Hawkeye64 last edited by

            @walfin You should be lazy-loading your images and in place, use QSkeleton until the image is available. If you load all your images at once, the time delay before the first screen is available will be horrendous.

            W 1 Reply Last reply Reply Quote 0
            • W
              walfin @Hawkeye64 last edited by

              @Hawkeye64 I was wondering if there was a way to start loading the images immediately after first paint (in the background). Currently the first opening of my menu sidebar is lagging as it only starts loading the images when the menu is opened. I’m currently resorting to using img instead of q-img and putting in invisible imgs elsewhere on the page to force the images to load.

              1 Reply Last reply Reply Quote 1
              • E
                eyedean last edited by eyedean

                @Hawkeye64 Like most technical questions in programming forums, this question can be answered in two ways:

                1. Hey, what you are trying to do (called X ) is not the recommended way. So, do Y instead. (An example of XY Problem – https://xyproblem.info/)
                2. Ok, let’s assume you know what you are doing and you have your own reasons to do X instead of the recommended way of Y. Here is the easiest way to achieve that.

                I believe your answer was case #1 above. And there are people who are looking for #2. As a core Quasar Team member, it would be wonderful to hear your answer to #2.


                What I have found is the common way of preloading in Javascript (https://stackoverflow.com/q/3646036 – just (new Image()).src = url;) does the work here. Note that q-img often loads the image twice (Read more details in my answer here: https://github.com/quasarframework/quasar/issues/7053#issuecomment-771938111), but the second time it’s from the cache. So if you want to test it, make sure you have Disable cache in Chrome DevTools unchecked.

                Additionally, I’ve found that adding basic and no-default-spinner to the q-img element can make it show up faster – from the API doc: https://quasar.dev/vue-components/img#qimg-api

                I still see some lags, but that’s the best I could come up with.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post