drupal 7

Drupal provided the lots of hook to extents its functionality, using this we can prevent a js file to load on particular page using HOOK_JS_ALTER

If you want to load a js on every page except some page, below example will help you to achieving this.

function mymodule_js_alter(&$javascript) {
    $path = current_path();
    if($path == "my-path")

Reference of HOOK_JS_ALTER is here.

You can do


to search your js and unset that according to location.


Please Comment your thoughts and feedback below and add something if you found good in anywhere to help others

Hit a like Button If you like the Post.

Many Thanks