pagePaintScript top-level constant

String const pagePaintScript

Implementation

const pagePaintScript = '''
(function () {
  function painted() {
    BemobiNativeSDKBridge.postMessage(JSON.stringify({ method: '$pagePaintedMethod' }));
  }
  var types = (typeof PerformanceObserver !== 'undefined' && PerformanceObserver.supportedEntryTypes) || [];
  if (types.indexOf('paint') < 0) return painted();
  var observer = new PerformanceObserver(function (list) {
    if (list.getEntries().length === 0) return;
    observer.disconnect();
    painted();
  });
  observer.observe({ type: 'paint', buffered: true });
})();
''';