When managing script logic in Google Apps Script—particularly with triggers—understanding how the execution environment handles multiple functions is key to avoiding "silent" failures.
Here is a consolidated and refined explanation of how these triggers behave across single and multiple projects.
Within a single Apps Script project—regardless of how many .gs files you have—all function names must be unique. If you have multiple functions with the same name, only the last one evaluated will exist in the script's memory.
How it works: The V8 engine scans all files in the project. If it finds function calculate() in the first file and function calculate() in the last file, the first version is completely discarded.
Simple Triggers: This is why you can only have one onEdit(e) or onOpen(e). The last one defined is the only one the system "sees" when an event occurs.
Evaluation Order: Files are evaluated in the order they appear in the file list. The function in the file closest to the bottom of the list is the one that survives.
The only scenario where you can have multiple active functions with the same name is by using multiple script projects bound to the same document (Spreadsheet, Doc, or Form).
Isolated Namespaces: Each project is its own sandbox. A function named getData() in Project A is completely separate from a getData() in Project B.
Parallel Execution: If both projects contain an onEdit(e) function, both will run independently when an edit occurs. This is the primary use case for multiple projects: allowing two separate scripts to respond to the same event without their internal functions overwriting one another.
Add-ons: This is how Add-ons operate. They run their own code (with their own onEdit logic) without conflicting with your personal scripts.
Installable triggers (e.g., Time-driven or "On form submit") behave differently because they are explicitly linked to a specific function in a specific project.
Project Specific: An installable trigger is created inside a project. If you have two projects, you must set up and manage triggers for each one individually via the "Triggers" (clock icon) dashboard.
Redundancy: If you set up an installable "On Edit" trigger in Project A and another in Project B, both will fire. If they both point to a function called runTask(), they will each execute the version of runTask() local to their own project.