Skip to content
Advertisement

Contents.js blocking page load chrome extension

Hey guys so I’m building an extension but I have a function that is heavy when running and it’s blocking the load of the page and I was wondering if it was possible to only run it after the page is fully loaded and interactive either in the script or in manifest.json?

I currently have it inside a window.onload but still blocks the interactiveness of the page.

The script:

JavaScript

Would this be possible if yes how can I achieve it?

Advertisement

Answer

Since the content script itself is trivial, the problem is caused by catastrophic backtracking inside the regular expression, specifically ([^EAN]*$)* which can match 0 characters at any place.

The solution is to use a look-behind condition:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement