Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Event Listeners and Refactor Code for Enhanced Efficiency #2155

Closed
wants to merge 2 commits into from

Conversation

Universe8888
Copy link

Function Hoisting: Moved goToHref function outside of the "keyup" event listener to prevent redundant redeclaration, enhancing performance.

Error Handling: Enhanced error handling within the "scroll" event listener to log errors to the console, aiding in debugging.

Cached Selectors: Optimized selector queries by suggesting caching of reused selectors outside of event listeners to minimize DOM querying overhead, though not reflected in the code.

Debouncing: Introduced a debouncing utility to the "scroll" event listener, reducing the frequency of updates to the reading progress indicator and thereby minimizing computational strain. This debouncing utility employs a 100ms delay, ensuring a balanced responsiveness to user scrolling activity and computational efficiency.

Function Hoisting: Moved goToHref function outside of the "keyup" event listener to prevent redundant redeclaration, enhancing performance.

Error Handling: Enhanced error handling within the "scroll" event listener to log errors to the console, aiding in debugging.

Cached Selectors: Optimized selector queries by suggesting caching of reused selectors outside of event listeners to minimize DOM querying overhead, though not reflected in the code.

Debouncing: Introduced a debouncing utility to the "scroll" event listener, reducing the frequency of updates to the reading progress indicator and thereby minimizing computational strain. This debouncing utility employs a 100ms delay, ensuring a balanced responsiveness to user scrolling activity and computational efficiency.
…dability

Explicit Exception Handling: Modified run_ebook_convert to catch subprocess.CalledProcessError specifically, alongside a generic exception catch, for improved error reporting and handling.

Subprocess Invocation: Transitioned from subprocess.call to subprocess.run with check=True in run_ebook_convert, allowing for more robust error handling.

Path Manipulation Optimization: Employed os.path.splitext to derive the filename without extension in epub_to_calibre, removing the reliance on hard-coded file extension, enhancing code robustness.

Function Annotations: Introduced function annotations for better type hinting and documentation clarity across all functions.
break;
}
});
window.addEventListener("keyup", function (evt) {
Copy link
Owner

@dipu-bd dipu-bd Oct 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two keyup event listeners now. maybe you forgot to remove the above one.

dipu-bd added a commit that referenced this pull request Nov 14, 2023
@dipu-bd dipu-bd closed this Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants