Please can any one tell me what's the difference between:
- adding a java script to a webform using js injector module
- adding it using Implements
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
Technically the difference is very small.
Whatever js you add in
$form['#attached']['js'] is added via drupal_add_js() when the form attachments are processed using drupal_process_attached() - just like the JS Injector Module adds js snippets using drupal_add_js().
The JS Injector page claims the js it serves is loaded last, so order is an aspect where the two approaches may differ, unless you do some manual adjusting of the loading order afterwards.
If you try to decide what to use - it really depends. If it is just a minor snippet you want to add, the injector has the advantage that you don't need to write an entire custom module just to add some minor js functionality. It might also be nice for front end designers who know js, but have little experience with php or writing modules. If the js to add is part of a larger module/functionality upgrade anyway though, there is little reason to make use of the JS Inspector Module.