diff --git a/README.md b/README.md index 6b70d27d..9fe3eb8d 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,8 @@ This will start a webserver on the default settings (http://localhost:8000) and If Chrome or Chromium is installed then by default it will open in that in App Mode (with the `--app` cmdline flag), regardless of what the OS's default browser is set to (it is possible to override this behaviour). +If you have large amounts of .html or .js files, eel.init() might take up a long time to scan those files for exposed functions. By passing a list of paths to the init function's exclude_path parameter you can exclude these files from being scanned. + ### App options Additional options can be passed to `eel.start()` as keyword arguments. diff --git a/eel/__init__.py b/eel/__init__.py index fd09b45b..cd5a45e2 100644 --- a/eel/__init__.py +++ b/eel/__init__.py @@ -111,7 +111,7 @@ def decorator(function: Callable[..., Any]) -> Any: def init(path: str, allowed_extensions: List[str] = ['.js', '.html', '.txt', '.htm', - '.xhtml', '.vue'], js_result_timeout: int = 10000) -> None: + '.xhtml', '.vue'], exclude_path: List[str] = [], js_result_timeout: int = 10000) -> None: global root_path, _js_functions, _js_result_timeout root_path = _get_real_path(path) @@ -121,6 +121,10 @@ def init(path: str, allowed_extensions: List[str] = ['.js', '.html', '.txt', '.h if not any(name.endswith(ext) for ext in allowed_extensions): continue + # exclude specific file paths to increase loading speed on initialisation + if any(exclude in os.path.join(root, name) for exclude in exclude_path): + continue + try: with open(os.path.join(root, name), encoding='utf-8') as file: contents = file.read()