Modularized trim-document

Using two functions in the main namespace, not a module (for now)
Removed callback check

No need to check if callback defined in listener because the listener is
only bound by the caller if there is a callback
Added comment
Modularized entry.js