This should do the trick: <!-- language-all: lang-el --> (add-hook 'web-mode-hook #'(lambda () (unless (and (stringp buffer-file-name) (string-match "\\.js\\'" buffer-file-name)) (aggressive-indent-mode)))) It activates `aggressive-indent-mode` only if file extension is not `js`. If you use `(global-aggressive-indent-mode 1)` you can disable it per this: (add-hook 'web-mode-hook #'(lambda () (when (and (stringp buffer-file-name) (string-match "\\.js\\'" buffer-file-name)) (aggressive-indent-mode 0)))) And finally, to disable it in javascript sections use these advices: (defun aggressive-indent-advice (org-fun &rest args) "Do not agressive-indent in javascript section of web-mode." (let ((agressive-indent t)) (when (equal major-mode 'web-mode) (setq agressive-indent (not (member (get-text-property (point) 'part-side) '(javascript))))) (when agressive-indent (apply org-fun args)))) (advice-add 'aggressive-indent--keep-track-of-changes :around #'aggressive-indent-advice) (advice-add 'aggressive-indent--indent-if-changed :around #'aggressive-indent-advice) (advice-add 'aggressive-indent--softly-indent-defun :around #'aggressive-indent-advice) Note that, depending on your need, you can use the former two hooks independently from `web-mode` to disable `aggressive-indent`. On the other hand, the depends on `web-mode`, but will also work for `.js` files in `web-mode`.