• Resolved quiron

    (@quiron)


    Hi! This plugin is really useful for all my team, but unfortunately the scripts added by it are deferring the Time To Interactive in our page.

    Will be great that you support loading it when the main browser thread is idle. This will help to improve the page speed index of all the users.

    Right now browsers start supporting the method requestIdleCallback:
    https://developers.google.com/web/updates/2015/08/using-requestidlecallback
    https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback
    And google dev doc also suggest a polify for it.

    I tested it locally and it works fine if in the file dist/scripts/public.js, line 2828 you do:

    
    - Utils.loadPixels();
    + // Polify from Google dev: https://developers.google.com/web/updates/2015/08/using-requestidlecallback
    + window.requestIdleCallback = window.requestIdleCallback ||function (cb) {
    +    var start = Date.now();
    +    return setTimeout(function () {
    +      cb({
    +        didTimeout: false,
    +        timeRemaining: function () {
    +          return Math.max(0, 50 - (Date.now() - start));
    +        }
    +      });
    +    }, 1);
    +  }
    + // Load pixel when the main thread is Idel.
    + window.requestIdleCallback(Utils.loadPixels, {timeout: 10000});
    

    For sure this can be a configurable option and customization time out or whatever.

    I would really appreciate see it in next version. Is there any repository to contribut the code?

    Thanks.

Viewing 1 replies (of 1 total)
  • Plugin Author PixelYourSite

    (@pixelyoursite)

    Hi Quiron,

    Thanks for the suggestion, we will definitely look into it. I can’t promise it will be part of the very next update, because we have something already prepared.

    We don’t have a public repository.

Viewing 1 replies (of 1 total)

The topic ‘Defer loading scripts to Idle time’ is closed to new replies.