The preferred way of modifying out-of-the-box Surf Web Scripts (see Web Scripts) is by using Surf Extension Modules to target the Web Script that should be replaced:
<extension>
<modules>
<module>
<id>Customize a Web Script</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>The path to the out-of-the-box Web Script you are overriding, such as org.alfresco.components.dashlets</targetPackageRoot>
<sourcePackageRoot>The path to your Web Script customizations, such as org.alfresco.tutorials.customization.webscript.controller</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
The Web Script files in your package should have the same names as the original ones that you are overriding. The Extension Modules section has all the details.
Out-of-the-box Surf Web Scripts used to be overridden by putting the modified files under alfresco/web-extension/site-webscripts/org/alfresco/... directory using the exact same path. This approach is no longer needed.