-
Notifications
You must be signed in to change notification settings - Fork 2
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
Define a new folder structure #76
Comments
Looking at the current structure of the project, there are some alarming things, namely the fact that the utilities package is a large part of the code base. With that in mind, one possible solution is to:
One other thing to keep in mind is to not run every bit of javascript in every page since this can slow down page loads. Instead (and as @LuisDuarte1 suggested) we should have a mapping from URLs to "Page scripts". My 2 cents on this is to have a centralized "page registry", kinda like: // pageRegistry.js
const pageMapping = {} // mapping: URL Regex -> Function
const registerPage = (pageUrlRegex, pageLoader) => pageMapping[pageUrlRegex] = pageLoader;
const loadPage = (pageUrl) => {
for (const urlRegex of pageMapping) {
if (pageUrl.match(urlRegex)) {
pageMapping[pageUrlRegex]();
return;
}
}
}
This way, when a page loads, you only need to run the corresponding loader. This is all based on personal experience and I invite other people to argue about the pros and cons of this structure and provide their own solutions.
|
Closed in #173 |
Leave suggestions below
The text was updated successfully, but these errors were encountered: