- form validation functionality.
- analytics tracking.
- AJAX calls.
adaptation/views/base.js file, the
Examine the following code snippet:
We need to remove the scripts because some scripts are located inside HTML elements which are not going to be used on the mobile site. As a result, we need to re-include the removed scripts back in our templates.
adaptation/templates/base.dust file, notice the reference to the
- rewrite the script functionality on mobile.
- remove a feature on mobile.
This approach is described in the following sections.
a. Keep only scripts with the .x-keep class
adaptation/views/base.js file, change the
desktopScripts key to:
context.desktopScripts = $('script.x-keep').remove();
b. Mark the global scripts to keep
adaptation/views/base.js file, add a line in the
preProcess section to mark the scripts to keep on every page.
For example, if you want to always keep all scripts that are found in the
<head> section, add the following line of code to the
c. Mark page-specific scripts to keep
In the view file associated with this page, add a line in the
preProcess section to mark the scripts to keep on this page.
Edit in GitHub